Documentation
¶
Index ¶
- func ConditionalLogger(logLevel string, l *zap.Logger, name string) func(next http.Handler) http.Handler
- func InitLog(lvl zap.AtomicLevel) *zap.Logger
- func Logger(l *zap.Logger, name string) func(next http.Handler) http.Handler
- func NewDefaultGormLogger(service string) gormlogger.Interface
- func NewGormLogger(service string, config gormlogger.Config) gormlogger.Interface
- type DebugLogger
- type GormLogger
- func (g *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (g *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (g *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (g *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (g *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})
- type OperationBuilder
- func (b *OperationBuilder) Build() *OperationTracer
- func (b *OperationBuilder) WithBool(key string, value bool) *OperationBuilder
- func (b *OperationBuilder) WithInt(key string, value int) *OperationBuilder
- func (b *OperationBuilder) WithIntPtr(key string, value *int) *OperationBuilder
- func (b *OperationBuilder) WithParam(key string, value any) *OperationBuilder
- func (b *OperationBuilder) WithRequestBody(key string, value any) *OperationBuilder
- func (b *OperationBuilder) WithString(key, value string) *OperationBuilder
- func (b *OperationBuilder) WithStringPtr(key string, value *string) *OperationBuilder
- func (b *OperationBuilder) WithUUID(key string, value uuid.UUID) *OperationBuilder
- func (b *OperationBuilder) WithUUIDPtr(key string, value *uuid.UUID) *OperationBuilder
- type OperationTracer
- type ResultBuilder
- func (b *ResultBuilder) Log()
- func (b *ResultBuilder) WithBool(key string, value bool) *ResultBuilder
- func (b *ResultBuilder) WithError(err error) *ResultBuilder
- func (b *ResultBuilder) WithInt(key string, value int) *ResultBuilder
- func (b *ResultBuilder) WithIntPtr(key string, value *int) *ResultBuilder
- func (b *ResultBuilder) WithParam(key string, value any) *ResultBuilder
- func (b *ResultBuilder) WithString(key, value string) *ResultBuilder
- func (b *ResultBuilder) WithStringPtr(key string, value *string) *ResultBuilder
- func (b *ResultBuilder) WithUUID(key string, value uuid.UUID) *ResultBuilder
- func (b *ResultBuilder) WithUUIDPtr(key string, value *uuid.UUID) *ResultBuilder
- type StepBuilder
- func (b *StepBuilder) Log()
- func (b *StepBuilder) WithBool(key string, value bool) *StepBuilder
- func (b *StepBuilder) WithInt(key string, value int) *StepBuilder
- func (b *StepBuilder) WithIntPtr(key string, value *int) *StepBuilder
- func (b *StepBuilder) WithParam(key string, value any) *StepBuilder
- func (b *StepBuilder) WithString(key, value string) *StepBuilder
- func (b *StepBuilder) WithStringPtr(key string, value *string) *StepBuilder
- func (b *StepBuilder) WithUUID(key string, value uuid.UUID) *StepBuilder
- func (b *StepBuilder) WithUUIDPtr(key string, value *uuid.UUID) *StepBuilder
- type StructuredLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConditionalLogger ¶
func ConditionalLogger(logLevel string, l *zap.Logger, name string) func(next http.Handler) http.Handler
ConditionalLogger returns HTTP request logging middleware only if log level is debug/trace
func NewDefaultGormLogger ¶ added in v0.2.1
func NewDefaultGormLogger(service string) gormlogger.Interface
NewDefaultGormLogger creates a GORM logger with default configuration
func NewGormLogger ¶ added in v0.2.1
func NewGormLogger(service string, config gormlogger.Config) gormlogger.Interface
NewGormLogger creates a new GORM logger that bridges to our structured logger
Types ¶
type DebugLogger ¶ added in v0.2.1
type DebugLogger = StructuredLogger
DebugLogger is an alias for backward compatibility
type GormLogger ¶ added in v0.2.1
type GormLogger struct {
// contains filtered or unexported fields
}
GormLogger implements the GORM logger interface using our structured logger
func (*GormLogger) Error ¶ added in v0.2.1
func (g *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
Error implements gorm logger interface
func (*GormLogger) Info ¶ added in v0.2.1
func (g *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
Info implements gorm logger interface
func (*GormLogger) LogMode ¶ added in v0.2.1
func (g *GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
LogMode implements gorm logger interface
type OperationBuilder ¶ added in v0.2.1
type OperationBuilder struct {
// contains filtered or unexported fields
}
OperationBuilder builds operation parameters fluently
func (*OperationBuilder) Build ¶ added in v0.2.1
func (b *OperationBuilder) Build() *OperationTracer
Build creates and starts the operation tracer
func (*OperationBuilder) WithBool ¶ added in v0.2.1
func (b *OperationBuilder) WithBool(key string, value bool) *OperationBuilder
WithBool adds a bool parameter
func (*OperationBuilder) WithInt ¶ added in v0.2.1
func (b *OperationBuilder) WithInt(key string, value int) *OperationBuilder
WithInt adds an int parameter
func (*OperationBuilder) WithIntPtr ¶ added in v0.2.1
func (b *OperationBuilder) WithIntPtr(key string, value *int) *OperationBuilder
WithIntPtr adds an int pointer parameter (nil-safe)
func (*OperationBuilder) WithParam ¶ added in v0.2.1
func (b *OperationBuilder) WithParam(key string, value any) *OperationBuilder
WithParam adds a generic parameter
func (*OperationBuilder) WithRequestBody ¶ added in v0.2.1
func (b *OperationBuilder) WithRequestBody(key string, value any) *OperationBuilder
func (*OperationBuilder) WithString ¶ added in v0.2.1
func (b *OperationBuilder) WithString(key, value string) *OperationBuilder
WithString adds a string parameter
func (*OperationBuilder) WithStringPtr ¶ added in v0.2.1
func (b *OperationBuilder) WithStringPtr(key string, value *string) *OperationBuilder
WithStringPtr adds a string pointer parameter (nil-safe)
func (*OperationBuilder) WithUUID ¶ added in v0.2.1
func (b *OperationBuilder) WithUUID(key string, value uuid.UUID) *OperationBuilder
WithUUID adds a UUID parameter
func (*OperationBuilder) WithUUIDPtr ¶ added in v0.2.1
func (b *OperationBuilder) WithUUIDPtr(key string, value *uuid.UUID) *OperationBuilder
WithUUIDPtr adds a UUID pointer parameter (nil-safe)
type OperationTracer ¶ added in v0.2.1
type OperationTracer struct {
*StructuredLogger
// contains filtered or unexported fields
}
OperationTracer tracks the progress of a business operation
func (*OperationTracer) Error ¶ added in v0.2.1
func (ot *OperationTracer) Error(err error) *ResultBuilder
Error creates an error result builder that logs at error level
func (*OperationTracer) Step ¶ added in v0.2.1
func (ot *OperationTracer) Step(step string) *StepBuilder
Step creates a step builder
func (*OperationTracer) Success ¶ added in v0.2.1
func (ot *OperationTracer) Success() *ResultBuilder
Success creates a result builder
type ResultBuilder ¶ added in v0.2.1
type ResultBuilder struct {
// contains filtered or unexported fields
}
ResultBuilder builds result data fluently
func (*ResultBuilder) Log ¶ added in v0.2.1
func (b *ResultBuilder) Log()
Log executes the result logging
func (*ResultBuilder) WithBool ¶ added in v0.2.1
func (b *ResultBuilder) WithBool(key string, value bool) *ResultBuilder
WithBool adds a bool parameter to the result
func (*ResultBuilder) WithError ¶ added in v0.2.1
func (b *ResultBuilder) WithError(err error) *ResultBuilder
WithError adds the error to the log (typically used with Failed())
func (*ResultBuilder) WithInt ¶ added in v0.2.1
func (b *ResultBuilder) WithInt(key string, value int) *ResultBuilder
WithInt adds an int parameter to the result
func (*ResultBuilder) WithIntPtr ¶ added in v0.2.1
func (b *ResultBuilder) WithIntPtr(key string, value *int) *ResultBuilder
WithIntPtr adds an int pointer parameter to the result (nil-safe)
func (*ResultBuilder) WithParam ¶ added in v0.2.1
func (b *ResultBuilder) WithParam(key string, value any) *ResultBuilder
WithParam adds a generic parameter to the result
func (*ResultBuilder) WithString ¶ added in v0.2.1
func (b *ResultBuilder) WithString(key, value string) *ResultBuilder
WithString adds a string parameter to the result
func (*ResultBuilder) WithStringPtr ¶ added in v0.2.1
func (b *ResultBuilder) WithStringPtr(key string, value *string) *ResultBuilder
WithStringPtr adds a string pointer parameter to the result (nil-safe)
func (*ResultBuilder) WithUUID ¶ added in v0.2.1
func (b *ResultBuilder) WithUUID(key string, value uuid.UUID) *ResultBuilder
WithUUID adds a UUID parameter to the result
func (*ResultBuilder) WithUUIDPtr ¶ added in v0.2.1
func (b *ResultBuilder) WithUUIDPtr(key string, value *uuid.UUID) *ResultBuilder
WithUUIDPtr adds a UUID pointer parameter to the result (nil-safe)
type StepBuilder ¶ added in v0.2.1
type StepBuilder struct {
// contains filtered or unexported fields
}
StepBuilder builds step data fluently
func (*StepBuilder) WithBool ¶ added in v0.2.1
func (b *StepBuilder) WithBool(key string, value bool) *StepBuilder
WithBool adds a bool parameter to the step
func (*StepBuilder) WithInt ¶ added in v0.2.1
func (b *StepBuilder) WithInt(key string, value int) *StepBuilder
WithInt adds an int parameter to the step
func (*StepBuilder) WithIntPtr ¶ added in v0.2.1
func (b *StepBuilder) WithIntPtr(key string, value *int) *StepBuilder
WithIntPtr adds an int pointer parameter to the step (nil-safe)
func (*StepBuilder) WithParam ¶ added in v0.2.1
func (b *StepBuilder) WithParam(key string, value any) *StepBuilder
WithParam adds a generic parameter to the step
func (*StepBuilder) WithString ¶ added in v0.2.1
func (b *StepBuilder) WithString(key, value string) *StepBuilder
WithString adds a string parameter to the step
func (*StepBuilder) WithStringPtr ¶ added in v0.2.1
func (b *StepBuilder) WithStringPtr(key string, value *string) *StepBuilder
WithStringPtr adds a string pointer parameter to the step (nil-safe)
func (*StepBuilder) WithUUID ¶ added in v0.2.1
func (b *StepBuilder) WithUUID(key string, value uuid.UUID) *StepBuilder
WithUUID adds a UUID parameter to the step
func (*StepBuilder) WithUUIDPtr ¶ added in v0.2.1
func (b *StepBuilder) WithUUIDPtr(key string, value *uuid.UUID) *StepBuilder
WithUUIDPtr adds a UUID pointer parameter to the step (nil-safe)
type StructuredLogger ¶ added in v0.2.1
type StructuredLogger struct {
// contains filtered or unexported fields
}
StructuredLogger provides structured logging for business services at specified level
func NewDebugLogger ¶ added in v0.2.1
func NewDebugLogger(service string) *StructuredLogger
NewDebugLogger creates a new debug-level structured logger for a specific service
func NewInfoLogger ¶ added in v0.2.1
func NewInfoLogger(service string) *StructuredLogger
NewInfoLogger creates a new info-level structured logger for a specific service
func NewStructuredLogger ¶ added in v0.2.1
func NewStructuredLogger(service string, level zapcore.Level) *StructuredLogger
NewStructuredLogger creates a new structured logger for a specific service at the given level
func NewWarnLogger ¶ added in v0.2.1
func NewWarnLogger(service string) *StructuredLogger
NewWarnLogger creates a new warn-level structured logger for a specific service
func (*StructuredLogger) Operation ¶ added in v0.2.1
func (l *StructuredLogger) Operation(operation string) *OperationBuilder
Operation begins operation tracing and returns a builder
func (*StructuredLogger) WithContext ¶ added in v0.2.1
func (l *StructuredLogger) WithContext(ctx context.Context) *StructuredLogger
WithContext returns a new StructuredLogger with request context