Documentation
¶
Index ¶
- Constants
- func Bind(ctx context.Context, fields ...LoggingField) context.Context
- func BindSummary(ctx context.Context, fields ...LoggingField) context.Context
- func RedactHeaderMap(headers http.Header, allowlist ...string) http.Header
- func RedactSecret(_ string) string
- func RedactURLString(raw string) string
- func RequestIDFromContext(ctx context.Context) string
- type AuditEvent
- type BoundLogger
- func (l *BoundLogger) Debug(msg string, fields ...LoggingField)
- func (l *BoundLogger) Error(msg string, fields ...LoggingField)
- func (l *BoundLogger) Fatal(msg string, fields ...LoggingField)
- func (l *BoundLogger) Info(msg string, fields ...LoggingField)
- func (l *BoundLogger) Log(level Level, msg string, fields ...LoggingField)
- func (l *BoundLogger) Sync() error
- func (l *BoundLogger) Warn(msg string, fields ...LoggingField)
- func (l *BoundLogger) With(fields ...LoggingField) *BoundLogger
- func (l *BoundLogger) WithAuditEvent(event AuditEvent) *BoundLogger
- type Config
- type Level
- type Logger
- func (l *Logger) Background() *BoundLogger
- func (l *Logger) Named(name string) *Logger
- func (l *Logger) SummaryWithContext(ctx context.Context) *BoundLogger
- func (l *Logger) Sync() error
- func (l *Logger) With(fields ...LoggingField) *Logger
- func (l *Logger) WithContext(ctx context.Context) *BoundLogger
- type LoggingField
- func AnyField(key string, value any) LoggingField
- func AuditField(event AuditEvent) LoggingField
- func BoolField(key string, value bool) LoggingField
- func Bytes(value int) LoggingField
- func Component(value string) LoggingField
- func CorrelationID(value string) LoggingField
- func Duration(value time.Duration) LoggingField
- func DurationField(key string, value time.Duration) LoggingField
- func ErrorField(err error) LoggingField
- func GRPCMethod(value string) LoggingField
- func HTTPMethod(value string) LoggingField
- func HTTPStatus(value int) LoggingField
- func Int64Field(key string, value int64) LoggingField
- func IntField(key string, value int) LoggingField
- func Operation(value string) LoggingField
- func Region(value string) LoggingField
- func RequestID(value string) LoggingField
- func StringField(key, value string) LoggingField
- func TenantID(value string) LoggingField
Constants ¶
View Source
const ( KeyAuditEvent = "audit_event" KeyRequestID = "request_id" KeyCorrelationID = "correlation_id" KeyTenantID = "tenant_id" KeyRegion = "region" KeyComponent = "component" KeyOperation = "operation" KeyHTTPMethod = "method" KeyHTTPStatus = "status" KeyGRPCMethod = "grpc_method" KeyDuration = "duration" KeyBytes = "bytes" )
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
func Bind(ctx context.Context, fields ...LoggingField) context.Context
Bind attaches structured fields to a plain context.Context. Later bindings override earlier values for the same field key.
func BindSummary ¶
func BindSummary(ctx context.Context, fields ...LoggingField) context.Context
BindSummary promotes fields into the request summary view without changing the ordinary fields visible to WithContext on the returned context.
func RedactSecret ¶
func RedactURLString ¶
func RequestIDFromContext ¶
RequestIDFromContext extracts `request_id` if it was previously bound as a string field.
Types ¶
type AuditEvent ¶
type AuditEvent string
const ( AuthnSuccess AuditEvent = "authn.success" AuthnFailure AuditEvent = "authn.failure" AuthzAllowed AuditEvent = "authz.allowed" AuthzDenied AuditEvent = "authz.denied" ResourceCreate AuditEvent = "resource.create" ResourceUpdate AuditEvent = "resource.update" ResourceDelete AuditEvent = "resource.delete" )
type BoundLogger ¶
type BoundLogger struct {
// contains filtered or unexported fields
}
func (*BoundLogger) Debug ¶
func (l *BoundLogger) Debug(msg string, fields ...LoggingField)
func (*BoundLogger) Error ¶
func (l *BoundLogger) Error(msg string, fields ...LoggingField)
func (*BoundLogger) Fatal ¶
func (l *BoundLogger) Fatal(msg string, fields ...LoggingField)
func (*BoundLogger) Info ¶
func (l *BoundLogger) Info(msg string, fields ...LoggingField)
func (*BoundLogger) Log ¶
func (l *BoundLogger) Log(level Level, msg string, fields ...LoggingField)
func (*BoundLogger) Sync ¶
func (l *BoundLogger) Sync() error
func (*BoundLogger) Warn ¶
func (l *BoundLogger) Warn(msg string, fields ...LoggingField)
func (*BoundLogger) With ¶
func (l *BoundLogger) With(fields ...LoggingField) *BoundLogger
func (*BoundLogger) WithAuditEvent ¶
func (l *BoundLogger) WithAuditEvent(event AuditEvent) *BoundLogger
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) Background ¶
func (l *Logger) Background() *BoundLogger
func (*Logger) SummaryWithContext ¶
func (l *Logger) SummaryWithContext(ctx context.Context) *BoundLogger
func (*Logger) With ¶
func (l *Logger) With(fields ...LoggingField) *Logger
func (*Logger) WithContext ¶
func (l *Logger) WithContext(ctx context.Context) *BoundLogger
type LoggingField ¶
type LoggingField struct {
// contains filtered or unexported fields
}
func AnyField ¶
func AnyField(key string, value any) LoggingField
func AuditField ¶
func AuditField(event AuditEvent) LoggingField
func BoolField ¶
func BoolField(key string, value bool) LoggingField
func Bytes ¶
func Bytes(value int) LoggingField
func Component ¶
func Component(value string) LoggingField
func CorrelationID ¶
func CorrelationID(value string) LoggingField
func Duration ¶
func Duration(value time.Duration) LoggingField
func DurationField ¶
func DurationField(key string, value time.Duration) LoggingField
func ErrorField ¶
func ErrorField(err error) LoggingField
func GRPCMethod ¶
func GRPCMethod(value string) LoggingField
func HTTPMethod ¶
func HTTPMethod(value string) LoggingField
func HTTPStatus ¶
func HTTPStatus(value int) LoggingField
func Int64Field ¶
func Int64Field(key string, value int64) LoggingField
func IntField ¶
func IntField(key string, value int) LoggingField
func Operation ¶
func Operation(value string) LoggingField
func Region ¶
func Region(value string) LoggingField
func RequestID ¶
func RequestID(value string) LoggingField
func StringField ¶
func StringField(key, value string) LoggingField
func TenantID ¶
func TenantID(value string) LoggingField
Click to show internal directories.
Click to hide internal directories.