Documentation
¶
Overview ¶
Package logger provides structured logging functionality for the multichain-go application. This package configures and creates zap loggers with appropriate settings for production and development environments, including HTTP request logging middleware.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HttpLoggerMiddleware ¶
HttpLoggerMiddleware creates an HTTP middleware for request logging. This middleware logs HTTP requests with method, path, and duration information. Health and ready check endpoints are excluded from logging to reduce noise.
Parameters:
- next: The next HTTP handler in the middleware chain
- l: The zap logger to use for request logging
Returns:
- http.Handler: An HTTP handler that logs requests and calls the next handler
func NewLogger ¶
NewLogger creates a new structured logger with the specified configuration. The logger is configured for production use with JSON encoding and ISO8601 timestamps. Debug mode can be enabled through the configuration to include debug-level logs.
Parameters:
- cfg: The logger configuration
- options: Additional zap options to apply to the logger
Returns:
- *zap.Logger: A configured zap logger instance
- error: An error if the logger cannot be created
Types ¶
type LoggerConfig ¶
type LoggerConfig struct {
// Debug enables debug-level logging when true, otherwise uses info level
Debug bool
}
LoggerConfig holds the configuration for logger creation. This configuration controls the logging level and behavior.