Documentation ¶
Index ¶
- Constants
- func New(level string, opts ...any)
- func OnExit()
- type Logger
- type Option
- type Resource
- type ResourceOption
- type Syncer
- type WrappedLogger
- func (l *WrappedLogger) Check(lvl string) bool
- func (wl *WrappedLogger) Close()
- func (l *WrappedLogger) DebugR(msg string, args ...any)
- func (l *WrappedLogger) ErrorR(msg string, args ...any)
- func (wl *WrappedLogger) FromContext(ctx context.Context) *WrappedLogger
- func (l *WrappedLogger) InfoR(msg string, args ...any)
- func (wl *WrappedLogger) WithIndex(key, value string) *WrappedLogger
- func (wl *WrappedLogger) WithOptions(opts ...Option) *WrappedLogger
- func (wl *WrappedLogger) WithServiceName(servicename string) *WrappedLogger
Constants ¶
const ( DebugLevel = "DEBUG" InfoLevel = "INFO" )
const ( // We repeat this constant here as we don't want the circular dependency // of importint our tracing package TraceIDKey = "x-b3-traceid" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates 2 loggers (plain and sugared) as global variables according to the desired loglevel ("DEBUG", "NOOP", "TEST", default is "INFO"). Additionally log output from other loggers in 3rd-party packages is redirected to the INFO label of these loggers. Both ResourceOption and zap.Option types are supported option types. The zap.Options are passed on the to zap logger.
Types ¶
type Logger ¶
type Logger interface { Debugf(string, ...any) DebugR(string, ...any) Infof(string, ...any) InfoR(string, ...any) Panicf(string, ...any) Check(string) bool FromContext(context.Context) *WrappedLogger WithIndex(string, string) *WrappedLogger WithServiceName(string) *WrappedLogger Close() WithOptions(...Option) *WrappedLogger }
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource - the counter is initialised with a zero value which indicates that the uber correction is made (default).
type ResourceOption ¶
type ResourceOption func(*Resource)
func WithConsole ¶
func WithConsole() ResourceOption
func WithFile ¶
func WithFile(filename string) ResourceOption
type WrappedLogger ¶
type WrappedLogger struct {
*zap.SugaredLogger
}
var ( Sugar *WrappedLogger Recorded *observer.ObservedLogs )
func (*WrappedLogger) Check ¶ added in v0.16.2
func (l *WrappedLogger) Check(lvl string) bool
func (*WrappedLogger) Close ¶
func (wl *WrappedLogger) Close()
Close attempts to flush any buffered log entries.
func (*WrappedLogger) DebugR ¶
func (l *WrappedLogger) DebugR(msg string, args ...any)
func (*WrappedLogger) ErrorR ¶
func (l *WrappedLogger) ErrorR(msg string, args ...any)
func (*WrappedLogger) FromContext ¶
func (wl *WrappedLogger) FromContext(ctx context.Context) *WrappedLogger
FromContext takes the trace ID from the current span and adds it to a child wrapped logger:
returns:
- the new wrapped logger with a context metadata value for traceID
This will be called on entry to a method or a function that has a context.Context.
func (*WrappedLogger) InfoR ¶
func (l *WrappedLogger) InfoR(msg string, args ...any)
func (*WrappedLogger) WithIndex ¶
func (wl *WrappedLogger) WithIndex(key, value string) *WrappedLogger
func (*WrappedLogger) WithOptions ¶
func (wl *WrappedLogger) WithOptions(opts ...Option) *WrappedLogger
func (*WrappedLogger) WithServiceName ¶
func (wl *WrappedLogger) WithServiceName(servicename string) *WrappedLogger