Documentation ¶
Overview ¶
Package logging package contains functionality for viam-server logging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLoggerConfig ¶ added in v0.12.0
NewLoggerConfig returns a new default logger config.
func ReplaceGlobal ¶ added in v0.12.0
func ReplaceGlobal(logger Logger)
ReplaceGlobal replaces the global loggers.
Types ¶
type Level ¶
type Level int
Level is an enum of log levels. Its value can be `DEBUG`, `INFO`, `WARN` or `ERROR`.
func LevelFromString ¶
LevelFromString parses an input string to a log level. The string must be one of `debug`, `info`, `warn` or `error`. The parsing is case-insensitive. An error is returned if the input does not match one of labeled cases.
func (Level) MarshalJSON ¶
MarshalJSON converts a log level to a json string.
func (*Level) UnmarshalJSON ¶
UnmarshalJSON converts a json string to a log level.
type Logger ¶ added in v0.12.0
type Logger interface { ZapCompatibleLogger AsZap() *zap.SugaredLogger }
Logger interface for logging to.
func FromZapCompatible ¶ added in v0.12.0
func FromZapCompatible(logger ZapCompatibleLogger) Logger
FromZapCompatible upconverts a ZapCompatibleLogger to a logging.Logger. If the argument already satisfies logging.Logger, no changes will be made. A nil input returns a nil logger. An input of unknown type will create a new logger that's not associated with the input.
func NewDebugLogger ¶ added in v0.12.0
NewDebugLogger returns a new logger using the default debug configuration.
func NewLogger ¶ added in v0.12.0
NewLogger returns a new logger using the default production configuration.
func NewObservedTestLogger ¶ added in v0.12.0
func NewObservedTestLogger(tb testing.TB) (Logger, *observer.ObservedLogs)
NewObservedTestLogger is like NewTestLogger but also saves logs to an in memory observer.
func NewTestLogger ¶ added in v0.12.0
NewTestLogger directs logs to the go test logger.
type ZapCompatibleLogger ¶ added in v0.12.0
type ZapCompatibleLogger interface { Desugar() *zap.Logger Level() zapcore.Level Named(name string) *zap.SugaredLogger Sync() error With(args ...interface{}) *zap.SugaredLogger WithOptions(opts ...zap.Option) *zap.SugaredLogger Debug(args ...interface{}) Debugf(template string, args ...interface{}) Debugw(msg string, keysAndValues ...interface{}) Info(args ...interface{}) Infof(template string, args ...interface{}) Infow(msg string, keysAndValues ...interface{}) Warn(args ...interface{}) Warnf(template string, args ...interface{}) Warnw(msg string, keysAndValues ...interface{}) Error(args ...interface{}) Errorf(template string, args ...interface{}) Errorw(msg string, keysAndValues ...interface{}) Fatal(args ...interface{}) Fatalf(template string, args ...interface{}) Fatalw(msg string, keysAndValues ...interface{}) }
ZapCompatibleLogger is a backwards compatibility layer for existing usages of the RDK as a library for Go application code or modules. Public (to the library) methods that take a logger as input should accept this type and upconvert to a Logger via a call to `FromZapCompatible`.