Documentation
¶
Index ¶
- func NewFileLogger(opts *FileLoggerOptions) (*lumberjack.Logger, error)
- func ParseLogLevel(level string) zap.AtomicLevel
- type FileLoggerOptions
- type Logger
- type LoggerOptions
- func (o *LoggerOptions) SetLogDirectory(directory string) *LoggerOptions
- func (o *LoggerOptions) SetLogFilePrefix(prefix string) *LoggerOptions
- func (o *LoggerOptions) SetLogFormat(format string) *LoggerOptions
- func (o *LoggerOptions) SetLogLevel(level string) *LoggerOptions
- func (o *LoggerOptions) SetLogOutput(output string) *LoggerOptions
- func (o *LoggerOptions) SetMaxFileSize(size int) *LoggerOptions
- func (o *LoggerOptions) Validate() error
- type MockLogger
- func (m *MockLogger) Debug(msg string, fields ...zapcore.Field)
- func (m *MockLogger) Error(msg string, fields ...zapcore.Field)
- func (m *MockLogger) Fatal(msg string, fields ...zapcore.Field)
- func (m *MockLogger) Info(msg string, fields ...zapcore.Field)
- func (m *MockLogger) Warn(msg string, fields ...zapcore.Field)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileLogger ¶
func NewFileLogger(opts *FileLoggerOptions) (*lumberjack.Logger, error)
func ParseLogLevel ¶
func ParseLogLevel(level string) zap.AtomicLevel
Types ¶
type FileLoggerOptions ¶
type Logger ¶
type Logger 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)
}
func NewLogger ¶
func NewLogger(options *LoggerOptions) (Logger, error)
NewLogger creates a new logger based on the provided options
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
}
func NewLoggerOptions ¶
func NewLoggerOptions() *LoggerOptions
func (*LoggerOptions) SetLogDirectory ¶
func (o *LoggerOptions) SetLogDirectory(directory string) *LoggerOptions
func (*LoggerOptions) SetLogFilePrefix ¶
func (o *LoggerOptions) SetLogFilePrefix(prefix string) *LoggerOptions
func (*LoggerOptions) SetLogFormat ¶
func (o *LoggerOptions) SetLogFormat(format string) *LoggerOptions
func (*LoggerOptions) SetLogLevel ¶
func (o *LoggerOptions) SetLogLevel(level string) *LoggerOptions
func (*LoggerOptions) SetLogOutput ¶
func (o *LoggerOptions) SetLogOutput(output string) *LoggerOptions
func (*LoggerOptions) SetMaxFileSize ¶
func (o *LoggerOptions) SetMaxFileSize(size int) *LoggerOptions
func (*LoggerOptions) Validate ¶
func (o *LoggerOptions) Validate() error
type MockLogger ¶
MockLogger implements the Logger interface for testing
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(msg string, fields ...zapcore.Field)
Debug logs a debug level message
func (*MockLogger) Error ¶
func (m *MockLogger) Error(msg string, fields ...zapcore.Field)
Error logs an error level message
func (*MockLogger) Fatal ¶
func (m *MockLogger) Fatal(msg string, fields ...zapcore.Field)
Fatal logs a fatal level message
Click to show internal directories.
Click to hide internal directories.