Documentation
¶
Overview ¶
Package logging provides a small public structured logging surface for GoWebComponents applications.
Index ¶
- func AttachBrowserConsole(parseConsoleOptions BrowserConsoleOptions) func()
- func ConfigureTelemetryRedaction(parsePolicy RedactionPolicy)
- func GetCorrelationID(parseCtx context.Context) string
- func Log(parseLogLevel, parseLogScope, parseLogMessage string, parseLogArgs ...any)
- func LogContext(parseLogContext context.Context, ...)
- func RedactStringMap(parsePath string, parseValues map[string]string) map[string]string
- func RedactTelemetryField(parsePath string, parseField string, parseValue any) (any, bool)
- func RedactTelemetryValue(parsePath string, parseValue any) any
- func StoreCorrelationID(parseCtx context.Context, parseCorrelationID string) context.Context
- func StoreTraceContext(parseCtx context.Context, parseTraceContext TraceContext) context.Context
- type BrowserConsoleOptions
- type Fields
- type Logger
- func (parseScopedLogger Logger) Debug(parseLogMessage string, parseLogArgs ...any)
- func (parseScopedLogger Logger) Error(parseLogMessage string, parseLogArgs ...any)
- func (parseScopedLogger Logger) Info(parseLogMessage string, parseLogArgs ...any)
- func (parseScopedLogger Logger) Log(parseLogLevel, parseLogMessage string, parseLogArgs ...any)
- func (parseScopedLogger Logger) Scope() string
- func (parseScopedLogger Logger) Warn(parseLogMessage string, parseLogArgs ...any)
- func (parseScopedLogger Logger) With(parseLogArgs ...any) Logger
- func (parseScopedLogger Logger) WithContext(parseLogContext context.Context) Logger
- type RedactionContext
- type RedactionPolicy
- type TraceContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachBrowserConsole ¶
func AttachBrowserConsole(parseConsoleOptions BrowserConsoleOptions) func()
AttachBrowserConsole is a no-op on non-browser targets.
func ConfigureTelemetryRedaction ¶
func ConfigureTelemetryRedaction(parsePolicy RedactionPolicy)
ConfigureTelemetryRedaction installs the current process-wide telemetry redaction policy. Passing the zero value disables policy-based redaction.
func GetCorrelationID ¶
GetCorrelationID returns the correlation ID stored by StoreCorrelationID.
func LogContext ¶
func LogContext(parseLogContext context.Context, parseLogLevel, parseLogScope, parseLogMessage string, parseLogArgs ...any)
LogContext writes a structured entry while resolving context-backed correlation and trace metadata.
func RedactStringMap ¶
RedactStringMap applies telemetry redaction to a string map and drops fields whose redactor fails.
func RedactTelemetryField ¶
RedactTelemetryField applies the active redaction policy to one field. The boolean return is false when the field must be dropped.
func RedactTelemetryValue ¶
RedactTelemetryValue recursively redacts JSON-like telemetry values.
func StoreCorrelationID ¶
StoreCorrelationID stores one correlation ID in ctx for later log enrichment.
func StoreTraceContext ¶
func StoreTraceContext(parseCtx context.Context, parseTraceContext TraceContext) context.Context
StoreTraceContext stores one trace context in ctx for later log enrichment.
Types ¶
type BrowserConsoleOptions ¶
type BrowserConsoleOptions struct {
Scope string
LogClicks bool
LogChanges bool
LogSubmits bool
LogWindowErrors bool
LogMount bool
LogDocumentReady bool
LogUnhandledRejections bool
LogVisibility bool
LogResize bool
LogBeforeUnload bool
}
BrowserConsoleOptions configures browser event logging on js/wasm builds.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes structured entries under a stable scope.
func NewContext ¶
NewContext returns a scoped logger that resolves correlation and trace metadata from context.
func (Logger) Log ¶
Log writes a structured entry using the provided level. Any fields attached via With are merged first (so per-call fields override them on a key collision).
func (Logger) With ¶
With returns a copy of the logger that attaches the given fields to every subsequent entry, so a component name, request id, or handler need not be repeated on each call. Accepts the same forms as the Log methods (key/value pairs, a Fields map, or slog.Attr). Per-call fields override With fields on a key collision. Mirrors slog.Logger.With.
type RedactionContext ¶
type RedactionContext = telemetryredaction.Context
RedactionContext describes one telemetry field being filtered.
type RedactionPolicy ¶
type RedactionPolicy = telemetryredaction.Policy
RedactionPolicy configures opt-in telemetry redaction for logs, panic reports, and devtools exports. Field names are matched case-insensitively against the final path segment. When Redact returns an error the field is dropped to fail closed.
func CurrentTelemetryRedaction ¶
func CurrentTelemetryRedaction() RedactionPolicy
CurrentTelemetryRedaction returns a copy of the active redaction policy.
type TraceContext ¶
type TraceContext struct {
TraceID string
ParentSpanID string
SpanID string
Flags string
TraceState string
}
TraceContext holds W3C trace-context identifiers for one logging scope.
func GetTraceContext ¶
func GetTraceContext(parseCtx context.Context) (TraceContext, bool)
GetTraceContext returns the trace context stored by StoreTraceContext.
func (TraceContext) IsValid ¶
func (parseTraceContext TraceContext) IsValid() bool
IsValid reports whether the trace context carries one usable 128-bit trace ID.
func (TraceContext) Traceparent ¶
func (parseTraceContext TraceContext) Traceparent() string
Traceparent formats the trace context as one W3C traceparent header value.