logging

package
v0.0.0-...-50e45a6 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileLogger

func NewFileLogger(opts *FileLoggerOptions) (*lumberjack.Logger, error)

func NewZapLogger

func NewZapLogger(opts *LoggerOptions) (*zap.Logger, error)

Create a new zap logger

func ParseLogLevel

func ParseLogLevel(level string) zap.AtomicLevel

Types

type FileLoggerOptions

type FileLoggerOptions struct {
	LogDirectory  string
	LogFilePrefix string
	MaxSize       int
	MaxAge        int
}

type Logger

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

func NewLogger

func NewLogger(opts *LoggerOptions) (*Logger, error)

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zapcore.Field)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zapcore.Field)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...zapcore.Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zapcore.Field)

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zapcore.Field)

type LoggerContract

type LoggerContract interface {
	Debug(msg string, fields ...zapcore.Field)
	Info(msg string, fields ...zapcore.Field)
	Warn(msg string, fields ...zapcore.Field)
	Error(msg string, fields ...zapcore.Field)
	Fatal(msg string, fields ...zapcore.Field)
}

type LoggerOptions

type LoggerOptions struct {
	// Log level: debug, info, warn, error, fatal
	LogLevel string
	// Where to output logs; console, file
	LogOutput string
	// Log output format: text, json
	LogFormat string
	// Log file prefix (only used when LogOutput is file)
	LogFilePrefix string
	// Log directory (only used when LogOutput is file)
	LogDirectory string
	// Max file size in MB (only used when LogOutput is file)
	MaxFileSize int
}

Jump to

Keyboard shortcuts

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