Documentation ¶
Index ¶
- Constants
- Variables
- func SetDefault(l Logger)
- func SetLevel(level slog.Level)
- type ContextKey
- type Logger
- type LoggerType
- type MockLogger
- func (m *MockLogger) Debug(msg string, args ...any)
- func (m *MockLogger) Debugf(format string, args ...any)
- func (m *MockLogger) Error(msg string, args ...any)
- func (m *MockLogger) Errorf(format string, args ...any)
- func (m *MockLogger) Fatal(msg string, args ...any)
- func (m *MockLogger) Fatalf(format string, args ...any)
- func (m *MockLogger) Info(msg string, args ...any)
- func (m *MockLogger) InfoContext(ctx context.Context, msg string, args ...any)
- func (m *MockLogger) Infof(format string, args ...any)
- func (m *MockLogger) Log(ctx context.Context, level slog.Level, msg string, args ...any)
- func (m *MockLogger) Notice(msg string, args ...any)
- func (m *MockLogger) Trace(msg string, args ...any)
- func (m *MockLogger) With(args ...any) Logger
- func (m *MockLogger) WithField(key string, value any) Logger
- func (m *MockLogger) WithFields(fields ...any) Logger
- func (m *MockLogger) WithRequestId(ctx context.Context) Logger
- func (m *MockLogger) WithRequestInfo(r *http.Request) Logger
- type SLogger
- func (s *SLogger) Debug(msg string, args ...any)
- func (s *SLogger) Debugf(format string, args ...any)
- func (s *SLogger) Error(msg string, args ...any)
- func (s *SLogger) Errorf(format string, args ...any)
- func (s *SLogger) Fatal(msg string, args ...any)
- func (s *SLogger) Fatalf(format string, args ...any)
- func (l *SLogger) Info(msg string, args ...any)
- func (s *SLogger) InfoContext(ctx context.Context, msg string, args ...any)
- func (l *SLogger) Infof(format string, args ...any)
- func (s *SLogger) Log(ctx context.Context, level slog.Level, msg string, args ...any)
- func (s *SLogger) Notice(msg string, args ...any)
- func (s *SLogger) Trace(msg string, args ...any)
- func (s *SLogger) With(args ...any) Logger
- func (s *SLogger) WithField(key string, value any) Logger
- func (s *SLogger) WithFields(fields ...any) Logger
- func (l *SLogger) WithRequestId(ctx context.Context) Logger
- func (l *SLogger) WithRequestInfo(r *http.Request) Logger
Constants ¶
Variables ¶
View Source
var LevelNames = map[slog.Leveler]string{ LevelTrace: "TRACE", LevelNotice: "NOTICE", LevelFatal: "FATAL", LevelError: "ERROR", LevelDebug: "DEBUG", LevelInfo: "INFO", }
Functions ¶
func SetDefault ¶
func SetDefault(l Logger)
Types ¶
type Logger ¶
type Logger interface { Trace(msg string, args ...any) Notice(msg string, args ...any) Error(msg string, args ...any) Fatal(msg string, args ...any) Fatalf(format string, args ...any) Errorf(format string, args ...any) Debug(msg string, args ...any) Debugf(format string, args ...any) InfoContext(ctx context.Context, msg string, args ...any) Info(msg string, args ...any) Infof(format string, args ...any) Log(ctx context.Context, level slog.Level, msg string, args ...any) With(args ...any) Logger WithRequestInfo(r *http.Request) Logger WithField(key string, value any) Logger WithFields(fields ...any) Logger WithRequestId(ctx context.Context) Logger }
type LoggerType ¶
type LoggerType string
const ( TYPE_JSON LoggerType = "json" TYPE_DEFAULT LoggerType = "default" )
type MockLogger ¶
type MockLogger struct{}
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(msg string, args ...any)
func (*MockLogger) Debugf ¶
func (m *MockLogger) Debugf(format string, args ...any)
func (*MockLogger) Error ¶
func (m *MockLogger) Error(msg string, args ...any)
func (*MockLogger) Errorf ¶
func (m *MockLogger) Errorf(format string, args ...any)
func (*MockLogger) Fatal ¶
func (m *MockLogger) Fatal(msg string, args ...any)
func (*MockLogger) Fatalf ¶
func (m *MockLogger) Fatalf(format string, args ...any)
func (*MockLogger) Info ¶
func (m *MockLogger) Info(msg string, args ...any)
func (*MockLogger) InfoContext ¶ added in v1.1.2
func (m *MockLogger) InfoContext(ctx context.Context, msg string, args ...any)
func (*MockLogger) Infof ¶
func (m *MockLogger) Infof(format string, args ...any)
func (*MockLogger) Notice ¶
func (m *MockLogger) Notice(msg string, args ...any)
func (*MockLogger) Trace ¶
func (m *MockLogger) Trace(msg string, args ...any)
func (*MockLogger) With ¶
func (m *MockLogger) With(args ...any) Logger
func (*MockLogger) WithFields ¶
func (m *MockLogger) WithFields(fields ...any) Logger
func (*MockLogger) WithRequestId ¶ added in v1.1.2
func (m *MockLogger) WithRequestId(ctx context.Context) Logger
func (*MockLogger) WithRequestInfo ¶
func (m *MockLogger) WithRequestInfo(r *http.Request) Logger
type SLogger ¶
type SLogger struct {
// contains filtered or unexported fields
}
func (*SLogger) InfoContext ¶ added in v1.1.2
func (*SLogger) WithFields ¶
Click to show internal directories.
Click to hide internal directories.