logger

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 5 Imported by: 0

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

func HttpLoggerMiddleware(next http.Handler, l *zap.Logger) http.Handler

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

func NewLogger(cfg *LoggerConfig, options ...zap.Option) (*zap.Logger, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL