logger

package module
v0.0.0-...-083b04a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 5 Imported by: 1

README

go-logger

Logger module for golang-based projects

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TracingParamsFromContext

func TracingParamsFromContext(ctx context.Context, params map[string]interface{}) map[string]interface{}

func WithTracingParams

func WithTracingParams(ctx context.Context, params map[string]interface{}) context.Context

Types

type LeafLogger

type LeafLogger interface {
	Debug(args ...interface{})
	Debugf(template string, args ...interface{})
	Debugw(msg string, keysAndValues ...interface{})
	Error(args ...interface{})
	Errorf(template string, args ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Info(args ...interface{})
	Infof(template string, args ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	SetLevel(level string)
	Sync() error
	Warn(args ...interface{})
	Warnf(template string, args ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
}

Same as standard Logger interface except the Named and With functions are removed to prohibit creation of a child Logger from this Logger. This is useful if a function consumes a logger and produces a new logger that should not be used as a parent. In practice, this is used by our APM code so that a logger created with a span_id and trace_id is not then used as a parent of a child that will then put a second set of span_id and trace_id tags. The logger implementation does not overwrite fields of a parent logger even if they are the same.

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(template string, args ...interface{})
	Debugw(msg string, keysAndValues ...interface{})
	Error(args ...interface{})
	Errorf(template string, args ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Info(args ...interface{})
	Infof(template string, args ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Named(name string) Logger
	SetLevel(level string)
	Sync() error
	Warn(args ...interface{})
	Warnf(template string, args ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	With(args ...interface{}) Logger
	WithTracingParams(ctx context.Context) Logger //params map[string]interface{},
	AsSugaredLogger() *zap.SugaredLogger
}

Standard Logger interface

func New

func New(loggerName, levelStr string) (Logger, error)

Returns a type backed by zap compliant with the Logger interface

type NoopLogger

type NoopLogger struct{}

func (*NoopLogger) AsSugaredLogger

func (n *NoopLogger) AsSugaredLogger() *zap.SugaredLogger

func (*NoopLogger) Debug

func (n *NoopLogger) Debug(args ...interface{})

func (*NoopLogger) Debugf

func (n *NoopLogger) Debugf(template string, args ...interface{})

func (*NoopLogger) Debugw

func (n *NoopLogger) Debugw(msg string, keysAndValues ...interface{})

func (*NoopLogger) Error

func (n *NoopLogger) Error(args ...interface{})

func (*NoopLogger) Errorf

func (n *NoopLogger) Errorf(template string, args ...interface{})

func (*NoopLogger) Errorw

func (n *NoopLogger) Errorw(msg string, keysAndValues ...interface{})

func (*NoopLogger) Info

func (n *NoopLogger) Info(args ...interface{})

func (*NoopLogger) Infof

func (n *NoopLogger) Infof(template string, args ...interface{})

func (*NoopLogger) Infow

func (n *NoopLogger) Infow(msg string, keysAndValues ...interface{})

func (*NoopLogger) Named

func (n *NoopLogger) Named(name string) Logger

func (*NoopLogger) SetLevel

func (n *NoopLogger) SetLevel(levelStr string)

func (*NoopLogger) Sync

func (n *NoopLogger) Sync() error

func (*NoopLogger) Warn

func (n *NoopLogger) Warn(args ...interface{})

func (*NoopLogger) Warnf

func (n *NoopLogger) Warnf(template string, args ...interface{})

func (*NoopLogger) Warnw

func (n *NoopLogger) Warnw(msg string, keysAndValues ...interface{})

func (*NoopLogger) With

func (n *NoopLogger) With(args ...interface{}) Logger

func (*NoopLogger) WithTracingParams

func (n *NoopLogger) WithTracingParams(ctx context.Context) Logger

type TracingProperties

type TracingProperties struct {
	CloudEventId       string
	ParentCloudEventId string
	ActivityId         string
	ParentActivityId   string
}

type ZapLogger

type ZapLogger struct {
	Log    *zap.SugaredLogger
	Config *zap.Config
}

func NewZapLogger

func NewZapLogger(loggerName, levelStr string) (*ZapLogger, error)

func (*ZapLogger) AsSugaredLogger

func (z *ZapLogger) AsSugaredLogger() *zap.SugaredLogger

func (*ZapLogger) Debug

func (z *ZapLogger) Debug(args ...interface{})

func (*ZapLogger) Debugf

func (z *ZapLogger) Debugf(template string, args ...interface{})

func (*ZapLogger) Debugw

func (z *ZapLogger) Debugw(msg string, keysAndValues ...interface{})

func (*ZapLogger) Error

func (z *ZapLogger) Error(args ...interface{})

func (*ZapLogger) Errorf

func (z *ZapLogger) Errorf(template string, args ...interface{})

func (*ZapLogger) Errorw

func (z *ZapLogger) Errorw(msg string, keysAndValues ...interface{})

func (*ZapLogger) Info

func (z *ZapLogger) Info(args ...interface{})

func (*ZapLogger) Infof

func (z *ZapLogger) Infof(template string, args ...interface{})

func (*ZapLogger) Infow

func (z *ZapLogger) Infow(msg string, keysAndValues ...interface{})

func (*ZapLogger) Named

func (z *ZapLogger) Named(name string) Logger

func (*ZapLogger) SetLevel

func (z *ZapLogger) SetLevel(levelStr string)

func (*ZapLogger) Sync

func (z *ZapLogger) Sync() error

func (*ZapLogger) Warn

func (z *ZapLogger) Warn(args ...interface{})

func (*ZapLogger) Warnf

func (z *ZapLogger) Warnf(template string, args ...interface{})

func (*ZapLogger) Warnw

func (z *ZapLogger) Warnw(msg string, keysAndValues ...interface{})

func (*ZapLogger) With

func (z *ZapLogger) With(args ...interface{}) Logger

func (*ZapLogger) WithTracingParams

func (z *ZapLogger) WithTracingParams(ctx context.Context) Logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL