Documentation
¶
Index ¶
- type LogLevel
- type Logger
- func (l *Logger) Debug(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) Error(ctx context.Context, msg string, err error, attrs ...slog.Attr)
- func (l *Logger) Fatal(ctx context.Context, msg string, err error, attrs ...slog.Attr)
- func (l *Logger) HTTPRequestLogger() func(next http.Handler) http.Handler
- func (l *Logger) Info(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) StartSpan(ctx context.Context, operationName string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func (l *Logger) Warn(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) WithFields(attrs ...slog.Attr) *Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel represents logging severity levels Maps to standard syslog levels for consistent interpretation
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wraps structured logging with OpenTelemetry integration Provides consistent logging interface across application components Automatically correlates logs with distributed traces for observability Time Complexity: O(1) for logging operations Space Complexity: O(1) per log entry
func NewLogger ¶
NewLogger creates structured logger with OpenTelemetry integration Configures JSON output for structured log parsing and correlation Initializes tracer for distributed tracing integration Time Complexity: O(1) - logger initialisation Space Complexity: O(1) - fixed logger structure
func (*Logger) Debug ¶
Debug logs debug-level message with context and trace correlation Used for detailed debugging information in development/troubleshooting Automatically includes trace and span IDs when available Time Complexity: O(1) - structured logging with fixed overhead Space Complexity: O(n) where n is message and attribute size
func (*Logger) Error ¶
Error logs error message with context and trace correlation Used for application errors and exception conditions Automatically marks associated span as error for tracing Time Complexity: O(1) - structured logging with fixed overhead Space Complexity: O(n) where n is message and attribute size
func (*Logger) Fatal ¶
Fatal logs fatal error and terminates application Used for unrecoverable errors requiring immediate shutdown Exits with code 1 after logging for monitoring systems Time Complexity: O(1) - logging followed by termination Space Complexity: O(n) where n is message and attribute size
func (*Logger) HTTPRequestLogger ¶
HTTPRequestLogger creates middleware for HTTP request logging Logs request details including method, path, status, and duration Integrates with OpenTelemetry for distributed request tracing Time Complexity: O(1) per request Space Complexity: O(1) for request metadata
func (*Logger) Info ¶
Info logs informational message with context and trace correlation Used for general application flow and business logic events Standard level for production operational logging Time Complexity: O(1) - structured logging with fixed overhead Space Complexity: O(n) where n is message and attribute size
func (*Logger) StartSpan ¶
func (l *Logger) StartSpan(ctx context.Context, operationName string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
StartSpan creates new OpenTelemetry span with logging context Provides distributed tracing for request flow and performance monitoring Automatically propagates trace context for downstream services Time Complexity: O(1) - span creation and context propagation Space Complexity: O(1) - span metadata storage
func (*Logger) Warn ¶
Warn logs warning message with context and trace correlation Used for recoverable errors and unexpected conditions Indicates potential issues requiring attention Time Complexity: O(1) - structured logging with fixed overhead Space Complexity: O(n) where n is message and attribute size
func (*Logger) WithFields ¶
WithFields creates logger with pre-configured attributes Useful for adding consistent context to related log entries Returns new logger instance to avoid modifying original Time Complexity: O(n) where n is number of attributes Space Complexity: O(n) for attribute storage