Documentation ¶
Index ¶
- func ToContext(ctx context.Context, logger Logger) context.Context
- type Logger
- type TestLogger
- func (tl *TestLogger) Debug(msg string)
- func (tl *TestLogger) Entries() []map[string]interface{}
- func (tl *TestLogger) Error(msg string)
- func (tl *TestLogger) Info(msg string)
- func (tl *TestLogger) IsDebug() bool
- func (tl *TestLogger) WithError(err error) Logger
- func (tl *TestLogger) WithInt(key string, val int) Logger
- func (tl *TestLogger) WithInt64(key string, val int64) Logger
- func (tl *TestLogger) WithString(key, val string) Logger
- type ZapWrapper
- func (zw ZapWrapper) Debug(msg string)
- func (zw ZapWrapper) Error(msg string)
- func (zw ZapWrapper) Info(msg string)
- func (zw ZapWrapper) IsDebug() bool
- func (zw ZapWrapper) WithError(err error) Logger
- func (zw ZapWrapper) WithInt(key string, val int) Logger
- func (zw ZapWrapper) WithInt64(key string, val int64) Logger
- func (zw ZapWrapper) WithString(key, val string) Logger
- func (zw ZapWrapper) WithUint64(key string, val uint64) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface { // WithString adds `val` of `string` type to the logging context and returns it to the caller. WithString(key, val string) Logger // WithInt64 adds `val` of `int64` type to the logging context and returns it to the caller. WithInt64(key string, val int64) Logger // WithInt adds `val` of `int` type to the logging context and returns it to the caller. WithInt(key string, val int) Logger // WithError adds `err` to the logging context and returns it to the caller. WithError(err error) Logger // Debug flushes logging context with "debug" severity level. Debug(msg string) // Info flushes logging context with "info" severity level. Info(msg string) // Error flushes logging context with "error" severity level. Error(msg string) // IsDebug reports if logging level severity is higher than 'debug' level. IsDebug() bool }
Logger is an abstraction used for logging in the service.
func FromContext ¶
FromContext extracts logger from the context. It will panic if context has no associated logger in it. It should be use in a pair with `ToContext` that injects logger into context.
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger should be used only for testing purposes.
func NewTestLogger ¶
func NewTestLogger() *TestLogger
func (*TestLogger) Debug ¶
func (tl *TestLogger) Debug(msg string)
func (*TestLogger) Entries ¶
func (tl *TestLogger) Entries() []map[string]interface{}
func (*TestLogger) Error ¶
func (tl *TestLogger) Error(msg string)
func (*TestLogger) Info ¶
func (tl *TestLogger) Info(msg string)
func (*TestLogger) IsDebug ¶
func (tl *TestLogger) IsDebug() bool
func (*TestLogger) WithError ¶
func (tl *TestLogger) WithError(err error) Logger
func (*TestLogger) WithString ¶
func (tl *TestLogger) WithString(key, val string) Logger
type ZapWrapper ¶
ZapWrapper is an adapter between service defined logging interface and zap logging implementation.
func NewZapLogger ¶
func NewZapLogger(lvl string) ZapWrapper
NewZapLogger returns a zap logger adapter to be used with `Logging` interface.
func (ZapWrapper) Debug ¶
func (zw ZapWrapper) Debug(msg string)
func (ZapWrapper) Error ¶
func (zw ZapWrapper) Error(msg string)
func (ZapWrapper) Info ¶
func (zw ZapWrapper) Info(msg string)
func (ZapWrapper) IsDebug ¶
func (zw ZapWrapper) IsDebug() bool
func (ZapWrapper) WithError ¶
func (zw ZapWrapper) WithError(err error) Logger
func (ZapWrapper) WithString ¶
func (zw ZapWrapper) WithString(key, val string) Logger
func (ZapWrapper) WithUint64 ¶
func (zw ZapWrapper) WithUint64(key string, val uint64) Logger
Click to show internal directories.
Click to hide internal directories.