Documentation
¶
Index ¶
- Constants
- Variables
- func CloseIfNeeded(closer io.Closer)
- func ErrorForLog(err error) string
- func LoggerWithContextIdentifiers(ctx context.Context, logger *slog.Logger) *slog.Logger
- func NewLogger(cfg *runtimeconfig.LoggingConfig, defaultWriter io.Writer) (*slog.Logger, io.Closer, error)
- func NewLoggerWithLevelController(cfg *runtimeconfig.LoggingConfig, defaultWriter io.Writer, ...) (*slog.Logger, io.Closer, error)
- func NewRoundTripper(base http.RoundTripper, logger *slog.Logger, cfg *runtimeconfig.LoggingConfig, ...) http.RoundTripper
- func ParseRuntimeLogLevel(raw string) (slog.Level, error)
- func RedactURL(u *url.URL) string
- func RedactURLString(raw string) string
- 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" ComponentCloudflared = "cloudflared" 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 ErrorForLog ¶ added in v0.0.11
ErrorForLog strips URL details from net/url errors while preserving wrapper and joined-error context. Callers remain responsible for not embedding raw URLs in ordinary error strings.
func LoggerWithContextIdentifiers ¶
LoggerWithContextIdentifiers returns a logger annotated with any identifiers stored on ctx.
func NewLogger ¶
func NewLogger(cfg *runtimeconfig.LoggingConfig, defaultWriter io.Writer) (*slog.Logger, io.Closer, error)
NewLogger constructs a slog.Logger configured according to the provided runtimeconfig. It returns the logger along with an optional closer that must be closed by the caller.
func NewLoggerWithLevelController ¶
func NewLoggerWithLevelController(cfg *runtimeconfig.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 *runtimeconfig.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 RedactURL ¶ added in v0.0.11
RedactURL returns only the URL origin for logging. URL userinfo, opaque data, path, query, and fragment components can contain credentials or other sensitive values and are intentionally omitted.
func RedactURLString ¶ added in v0.0.11
RedactURLString parses raw as a URL and returns its origin for logging.
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 *runtimeconfig.LoggingConfig) (*LevelController, error)
NewLevelController initializes a mutable level controller from the startup runtimeconfig.
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.