logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

README

logger

Centralized logging system that provides structured logging capabilities throughout the application.

Notes

  • Uses zerodha/logf for structured logging
  • Configures logging level based on application settings
  • Supports various output formats and destinations
  • Provides consistent logging interface across the application
  • Includes helper functions for different log levels (info, debug, error)
  • Enables file-based logging with rotation capabilities
  • Facilitates context-aware logging with additional metadata
  • Supports both development and production logging configurations

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// UserCurrentFunc is a variable that holds the function to get the current user.
	// It's exported for testing purposes to allow mocking.
	UserCurrentFunc = user.Current
)

Functions

func GetDefaultOpts added in v0.8.0

func GetDefaultOpts() logf.Opts

GetDefaultOpts returns a copy of the default logger options. This is useful for tests that need to modify options for a specific logger instance.

func GetLogger

func GetLogger(level string, filePath ...string) *logf.Logger

GetLogger returns the singleton instance of the logger. If filePath is provided (typically by InitFileLogger), it attempts to set up file logging. Otherwise, or if file opening fails, it defaults to stdout. The 'level' and 'filePath' parameters are only effective on the first call that initializes the logger.

func InitFileLogger added in v0.8.0

func InitFileLogger(configuredLevel string, appName string) (*logf.Logger, error)

InitFileLogger sets up the global logger with file output. It ensures the log directory exists and creates a timestamped log file.

func LoggingMiddleware added in v0.8.0

func LoggingMiddleware(log *logf.Logger) gin.HandlerFunc

LoggingMiddleware returns a Gin middleware that logs all HTTP requests with details.

func Reset

func Reset()

Reset is for testing so that we can reset the logger singleton

Types

This section is empty.

Jump to

Keyboard shortcuts

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