Documentation
¶
Overview ¶
Package logger is a generated GoMock package.
Index ¶
- func NewDefaultLogger(mode string) *defaultLogger
- type Field
- func Any(key string, value any) Field
- func Bool(key string, value bool) Field
- func Error(err error) Field
- func Float(key string, value float64) Field
- func Int(key string, value int) Field
- func RequestIDField(requestID string) Field
- func String(key, value string) Field
- func TenantIDField(tenantID string) Field
- func Time(key string, value time.Time) Field
- func UserField(userID string) Field
- type Level
- type Logger
- type MockLogger
- func (m *MockLogger) DPanic(msg string, fields ...Field)
- func (m *MockLogger) Debug(msg string, fields ...Field)
- func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
- func (m *MockLogger) Error(msg string, fields ...Field)
- func (m *MockLogger) Fatal(msg string, fields ...Field)
- func (m *MockLogger) Info(msg string, fields ...Field)
- func (m *MockLogger) Panic(msg string, fields ...Field)
- func (m *MockLogger) Sync() error
- func (m *MockLogger) Warn(msg string, fields ...Field)
- type MockLoggerMockRecorder
- func (mr *MockLoggerMockRecorder) DPanic(msg any, fields ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Debug(msg any, fields ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Error(msg any, fields ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Fatal(msg any, fields ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Info(msg any, fields ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Panic(msg any, fields ...any) *gomock.Call
- func (mr *MockLoggerMockRecorder) Sync() *gomock.Call
- func (mr *MockLoggerMockRecorder) Warn(msg any, fields ...any) *gomock.Call
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultLogger ¶
func NewDefaultLogger(mode string) *defaultLogger
NewDefaultLogger creates a new DefaultLogger.
Types ¶
type Field ¶
Field represents a key-value pair for structured logging.
func RequestIDField ¶
func TenantIDField ¶
type Level ¶
type Level int8
const ( // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel Level = iota - 2 // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // InfoLevel is the default logging priority. // General operational entries about what's going on inside the application. InfoLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. ErrorLevel // FatalLevel level. Logs and then calls `logger.Exit(1)`. highest level of severity. FatalLevel )
func GetLevel ¶
GetLevel converts a level string into a logger Level value. returns an error if the input string does not match known values.
type Logger ¶
type Logger interface { // Debug logs messages at the debug level, typically used for low-level system information. Debug(msg string, fields ...Field) // Info logs informational messages that highlight the progress of the application. Info(msg string, fields ...Field) // Warn logs messages that indicate potentially harmful situations. Warn(msg string, fields ...Field) // Error logs error messages that indicate a failure in the application. Error(msg string, fields ...Field) // DPanic logs messages at the DPanic level, which is between Debug and Panic levels. It is used to log critical issues that are considered panics in development environments but are treated differently in production. DPanic(msg string, fields ...Field) // Panic logs messages at the panic level and then panics. Panic(msg string, fields ...Field) // Fatal logs messages at the fatal level and then calls os.Exit(1). Fatal(msg string, fields ...Field) // Sync flushes any buffered log entries. Sync() error }
var DefaultLogger Logger
Logger defines the interface for logging at various levels. Logger is an interface that defines a set of methods for logging messages at various levels of severity. The levels include Debug, Info, Warn, Error, DPanic, Panic, and Fatal. Each method accepts a message string and optional fields for additional context. The Sync method is used to flush any buffered log entries.
type MockLogger ¶
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger is a mock of Logger interface.
func NewMockLogger ¶
func NewMockLogger(ctrl *gomock.Controller) *MockLogger
NewMockLogger creates a new mock instance.
func (*MockLogger) DPanic ¶
func (m *MockLogger) DPanic(msg string, fields ...Field)
DPanic mocks base method.
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(msg string, fields ...Field)
Debug mocks base method.
func (*MockLogger) EXPECT ¶
func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLogger) Error ¶
func (m *MockLogger) Error(msg string, fields ...Field)
Error mocks base method.
func (*MockLogger) Fatal ¶
func (m *MockLogger) Fatal(msg string, fields ...Field)
Fatal mocks base method.
func (*MockLogger) Info ¶
func (m *MockLogger) Info(msg string, fields ...Field)
Info mocks base method.
func (*MockLogger) Panic ¶
func (m *MockLogger) Panic(msg string, fields ...Field)
Panic mocks base method.
func (*MockLogger) Warn ¶
func (m *MockLogger) Warn(msg string, fields ...Field)
Warn mocks base method.
type MockLoggerMockRecorder ¶
type MockLoggerMockRecorder struct {
// contains filtered or unexported fields
}
MockLoggerMockRecorder is the mock recorder for MockLogger.
func (*MockLoggerMockRecorder) DPanic ¶
func (mr *MockLoggerMockRecorder) DPanic(msg any, fields ...any) *gomock.Call
DPanic indicates an expected call of DPanic.
func (*MockLoggerMockRecorder) Debug ¶
func (mr *MockLoggerMockRecorder) Debug(msg any, fields ...any) *gomock.Call
Debug indicates an expected call of Debug.
func (*MockLoggerMockRecorder) Error ¶
func (mr *MockLoggerMockRecorder) Error(msg any, fields ...any) *gomock.Call
Error indicates an expected call of Error.
func (*MockLoggerMockRecorder) Fatal ¶
func (mr *MockLoggerMockRecorder) Fatal(msg any, fields ...any) *gomock.Call
Fatal indicates an expected call of Fatal.
func (*MockLoggerMockRecorder) Info ¶
func (mr *MockLoggerMockRecorder) Info(msg any, fields ...any) *gomock.Call
Info indicates an expected call of Info.
func (*MockLoggerMockRecorder) Panic ¶
func (mr *MockLoggerMockRecorder) Panic(msg any, fields ...any) *gomock.Call
Panic indicates an expected call of Panic.
func (*MockLoggerMockRecorder) Sync ¶
func (mr *MockLoggerMockRecorder) Sync() *gomock.Call
Sync indicates an expected call of Sync.
type Provider ¶
type Provider interface { // Debug logs messages at the debug level, typically used for low-level system information. Debug(msg string, fields map[string]any) // Info logs informational messages that highlight the progress of the application. Info(msg string, fields map[string]any) // Warn logs messages that indicate potentially harmful situations. Warn(msg string, fields map[string]any) // Error logs error messages that indicate a failure in the application. Error(msg string, fields map[string]any) // DPanic logs messages at the DPanic level, which is between Debug and Panic levels. It is used to log critical issues that are considered panics in development environments but are treated differently in production. DPanic(msg string, fields map[string]any) // Panic logs messages at the panic level and then panics. Panic(msg string, fields map[string]any) // Fatal logs messages at the fatal level and then calls os.Exit(1). Fatal(msg string, fields map[string]any) // Sync flushes any buffered log entries. Sync() error }