log

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FieldComponent is the structured logging key used to describe the emitting sub-component.
	FieldComponent = "component"

	// FieldRequestID is the structured logging key for the MCP request identifier. This id assigned by control plane.
	FieldRequestID = "request_id"

	// FieldRpcRequestID is a Request identifier, which is defined by the spec to be a string, integer, or null.
	// https://www.jsonrpc.org/specification#request_object
	FieldRpcRequestID = "rpc_request_id"

	// FieldSessionID is the structured logging key that records the MCP session identifier.
	FieldSessionID = "session_id"

	// FieldControlPlaneCommandRequestID captures the upstream X-Request-Id issued by
	// plugin-service/connectors while they communicate with tunnel-service.
	FieldControlPlaneCommandRequestID = "cmd_request_id"

	// FieldTunnelServiceRequestID captures the X-Request-Id returned when the tunnel-client
	// talks directly to tunnel-service (e.g. poll, post response).
	FieldTunnelServiceRequestID = "tunnel_request_id"

	// FieldTunnelID is the stable structured logging key for the configured tunnel identifier.
	FieldTunnelID = "tunnel_id"

	// FieldClientInstanceID is the process-scoped correlation key shared with tunnel-service.
	FieldClientInstanceID = "client_instance_id"

	ComponentHealth       = "health"
	ComponentDispatcher   = "dispatcher"
	ComponentControlPlane = "controlplane"
	ComponentMcpClient    = "mcpclient"
	ComponentProcess      = "process"
	ComponentHarpoon      = "harpoon"
)

Variables

View Source
var Module = fx.Module("logger", fx.Provide(newLevelController, newLogger))

Module exposes the logger as an Fx module that owns the lifecycle of any resources it creates.

Functions

func CloseIfNeeded

func CloseIfNeeded(closer io.Closer)

CloseIfNeeded closes the provided closer if it is non-nil, ignoring already-closed errors.

func LoggerWithContextIdentifiers

func LoggerWithContextIdentifiers(ctx context.Context, logger *slog.Logger) *slog.Logger

LoggerWithContextIdentifiers returns a logger annotated with any identifiers stored on ctx.

func NewLogger

func NewLogger(cfg *config.LoggingConfig, defaultWriter io.Writer) (*slog.Logger, io.Closer, error)

NewLogger constructs a slog.Logger configured according to the provided config. It returns the logger along with an optional closer that must be closed by the caller.

func NewLoggerWithLevelController

func NewLoggerWithLevelController(cfg *config.LoggingConfig, defaultWriter io.Writer, controller *LevelController) (*slog.Logger, io.Closer, error)

NewLoggerWithLevelController constructs a slog.Logger backed by the provided level controller.

func NewRoundTripper

func NewRoundTripper(base http.RoundTripper, logger *slog.Logger, cfg *config.LoggingConfig, component string) http.RoundTripper

NewRoundTripper constructs a RoundTripper that logs raw HTTP traffic when the provided logging config enables it. The component name, when non-empty, is attached to the emitted logs via the FieldComponent attribute.

func ParseRuntimeLogLevel

func ParseRuntimeLogLevel(raw string) (slog.Level, error)

func SupportedRuntimeLogLevels

func SupportedRuntimeLogLevels() []string

Types

type LevelController

type LevelController struct {
	// contains filtered or unexported fields
}

LevelController exposes the live slog level used by tunnel-client handlers.

func NewLevelController

func NewLevelController(cfg *config.LoggingConfig) (*LevelController, error)

NewLevelController initializes a mutable level controller from the startup config.

func (*LevelController) Level

func (c *LevelController) Level() slog.Level

func (*LevelController) LevelString

func (c *LevelController) LevelString() string

func (*LevelController) LevelVar

func (c *LevelController) LevelVar() *slog.LevelVar

func (*LevelController) Set

func (c *LevelController) Set(level slog.Level)

func (*LevelController) SetString

func (c *LevelController) SetString(raw string) (slog.Level, error)

type LoggingRoundTripper

type LoggingRoundTripper struct {
	// contains filtered or unexported fields
}

LoggingRoundTripper wraps a base RoundTripper and emits raw HTTP request and response dumps when enabled.

func (*LoggingRoundTripper) RoundTrip

func (l *LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip logs raw request and response dumps surrounding the underlying transport call.

type Sink

type Sink interface {
	Handle(ctx context.Context, record slog.Record)
}

Sink receives a copy of each log record emitted by the tunnel-client logger.

Implementations MUST NOT retain slog.Record beyond the scope of Handle unless they first clone or fully materialize it, since slog.Record may reference transient state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL