Documentation
¶
Index ¶
- Constants
- func CloseGlobalLogger() error
- func Debug(message string)
- func Debugf(format string, args ...interface{})
- func Error(message string)
- func ErrorWithErr(message string, err error)
- func Errorf(format string, args ...interface{})
- func Fatal(message string)
- func FatalWithErr(message string, err error)
- func Fatalf(format string, args ...interface{})
- func Info(message string)
- func Infof(format string, args ...interface{})
- func InitializeGlobalLogger(config LoggerConfig) error
- func SetupLogger() error
- func Warn(message string)
- func Warnf(format string, args ...interface{})
- type LogEntry
- type LogLevel
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(message string)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(message string)
- func (l *Logger) ErrorWithErr(message string, err error)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(message string)
- func (l *Logger) FatalWithErr(message string, err error)
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(message string)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Warn(message string)
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) WithContext(ctx context.Context) *Logger
- func (l *Logger) WithField(key string, value interface{}) *Logger
- func (l *Logger) WithFields(fields map[string]interface{}) *Logger
- type LoggerConfig
Constants ¶
const ( ErrCreateLogsFileMsg = "error creating log file: %w" ErrCreateLogsDirMsg = "error creating logs directory: %w" )
Error messages
const LogsDirPath = "logs"
Variables ¶
This section is empty.
Functions ¶
func ErrorWithErr ¶
func FatalWithErr ¶
func InitializeGlobalLogger ¶
func InitializeGlobalLogger(config LoggerConfig) error
InitializeGlobalLogger initializes the global logger
func SetupLogger ¶
func SetupLogger() error
Types ¶
type LogEntry ¶
type LogEntry struct {
Timestamp string `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
Fields map[string]interface{} `json:"fields,omitempty"`
Caller string `json:"caller,omitempty"`
Error string `json:"error,omitempty"`
}
LogEntry represents a structured log entry
type LogLevel ¶
type LogLevel int
LogLevel represents the log level
func ParseLogLevel ¶
ParseLogLevel converts string to LogLevel
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a structured and efficient logger
var GlobalLogger *Logger
Global logger for convenience
func NewLogger ¶
func NewLogger(config LoggerConfig) (*Logger, error)
NewLogger creates a new logger instance
func WithContext ¶
WithContext creates a logger with context
func WithFields ¶
WithFields creates a logger with additional fields
func (*Logger) ErrorWithErr ¶
func (*Logger) FatalWithErr ¶
func (*Logger) WithContext ¶
WithContext adds context fields if available
func (*Logger) WithFields ¶
WithFields adds multiple fields to the logger