Documentation
¶
Index ¶
- Constants
- Variables
- func CloseIfNeeded(closer io.Closer)
- func LoggerWithContextIdentifiers(ctx context.Context, logger *slog.Logger) *slog.Logger
- func NewLogger(cfg *config.LoggingConfig, defaultWriter io.Writer) (*slog.Logger, io.Closer, error)
- func NewLoggerWithLevelController(cfg *config.LoggingConfig, defaultWriter io.Writer, ...) (*slog.Logger, io.Closer, error)
- func NewRoundTripper(base http.RoundTripper, logger *slog.Logger, cfg *config.LoggingConfig, ...) http.RoundTripper
- func ParseRuntimeLogLevel(raw string) (slog.Level, error)
- func SupportedRuntimeLogLevels() []string
- type LevelController
- type LoggingRoundTripper
- type Sink
Constants ¶
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 ¶
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 ¶
CloseIfNeeded closes the provided closer if it is non-nil, ignoring already-closed errors.
func LoggerWithContextIdentifiers ¶
LoggerWithContextIdentifiers returns a logger annotated with any identifiers stored on ctx.
func NewLogger ¶
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 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)
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.