Help us shape the future of Go! Take the 2026 Go Developer Survey

logger

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel int

LogLevel defines the log levels

const (
	DEBUG LogLevel = iota // DEBUG level log
	INFO                  // INFO level log
	WARN                  // WARN level log
	ERROR                 // ERROR level log
)

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a custom logger

func NewLogger

func NewLogger(config LoggerConfig) (*Logger, error)

NewLogger creates a new Logger instance (singleton pattern)

func (*Logger) Close

func (l *Logger) Close() error

Close closes the log file handle and releases resources, and closes the buffer channel

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

Debug logs a message at DEBUG level

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

Error logs a message at ERROR level

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

Info logs a message at INFO level

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

SetLevel sets the log level

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

Warn logs a message at WARN level

type LoggerConfig

type LoggerConfig struct {
	Level      LogLevel // Log level
	FilePath   string   // Log file path
	MaxSize    int64    // Maximum size of a single log file (bytes)
	MaxBackups int      // Maximum number of old log files to retain
	MaxAge     int      // Maximum number of days to retain old log files
	Compress   bool     // Whether to compress old log files
}

LoggerConfig is the configuration structure for Logger

Jump to

Keyboard shortcuts

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