Documentation ¶
Index ¶
- Constants
- func CleanUp() error
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Debugw(msg string, keysAndValues Fields)
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Errorw(msg string, keysAndValues Fields)
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func Fatalw(msg string, keysAndValues Fields)
- func GetPackageLogLevel(packageName ...string) (int, error)
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func Infow(msg string, keysAndValues Fields)
- func InitLogging()
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Panicw(msg string, keysAndValues Fields)
- func SetAllLogLevel(level int)
- func SetLogLevel(level int) error
- func SetPackageLogLevel(packageName string, level int)
- func ShortTimeEncoder(t time.Time, enc zc.PrimitiveArrayEncoder)
- func UpdateAllLoggers(defaultFields Fields) error
- func V(level int) bool
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- func Warnln(args ...interface{})
- func Warnw(msg string, keysAndValues Fields)
- type Fields
- type Logger
Constants ¶
const ( // DebugLevel logs a message at debug level DebugLevel = iota // InfoLevel logs a message at info level InfoLevel // TraceLevel logs a message at trace level TraceLevel // WarnLevel logs a message at warning level WarnLevel // ErrorLevel logs a message at error level ErrorLevel // PanicLevel logs a message, then panics. PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel )
const CONSOLE = "console"
CONSOLE formats the log for the console, mostly used during development
const JSON = "json"
JSON formats the log using json format, mostly used by an automated logging system consumption
Variables ¶
This section is empty.
Functions ¶
func CleanUp ¶
func CleanUp() error
CleanUp flushed any buffered log entries. Applications should take care to call CleanUp before exiting.
func Debug ¶
func Debug(args ...interface{})
Debug logs a message at level Debug on the standard logger.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the standard logger.
func Debugln ¶
func Debugln(args ...interface{})
Debugln logs a message at level Debug on the standard logger.
func Debugw ¶
Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func Error ¶
func Error(args ...interface{})
Error logs a message at level Error on the standard logger.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the standard logger.
func Errorln ¶
func Errorln(args ...interface{})
Errorln logs a message at level Error on the standard logger.
func Errorw ¶
Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs a message at level Fatal on the standard logger.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs a message at level Fatal on the standard logger.
func Fatalln ¶
func Fatalln(args ...interface{})
Fatalln logs a message at level Fatal on the standard logger.
func Fatalw ¶
Fatalw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func GetPackageLogLevel ¶
GetPackageLogLevel returns the current log level of a package.
func Info ¶
func Info(args ...interface{})
Info logs a message at level Info on the standard logger.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a message at level Info on the standard logger.
func Infoln ¶
func Infoln(args ...interface{})
Infoln logs a message at level Info on the standard logger.
func Infow ¶
Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func Panic ¶
func Panic(args ...interface{})
Panic logs a message at level Panic on the standard logger.
func Panicf ¶
func Panicf(format string, args ...interface{})
Panicf logs a message at level Panic on the standard logger.
func Panicln ¶
func Panicln(args ...interface{})
Panicln logs a message at level Panic on the standard logger.
func Panicw ¶
Panicw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func SetAllLogLevel ¶
func SetAllLogLevel(level int)
SetAllLogLevel sets the log level of all registered packages to level
func SetLogLevel ¶
SetLogLevel sets the log level for the logger corresponding to the caller's package
func SetPackageLogLevel ¶
SetPackageLogLevel dynamically sets the log level of a given package to level. This is typically invoked at an application level during debugging
func ShortTimeEncoder ¶
func ShortTimeEncoder(t time.Time, enc zc.PrimitiveArrayEncoder)
Short string with microsecond precision
func UpdateAllLoggers ¶
UpdateAllLoggers create new loggers for all registered packages with the defaultFields.
func Warn ¶
func Warn(args ...interface{})
Warn logs a message at level Warn on the standard logger.
func Warnf ¶
func Warnf(format string, args ...interface{})
Warnf logs a message at level Warn on the standard logger.
func Warning ¶
func Warning(args ...interface{})
Warning logs a message at level Warn on the standard logger.
func Warningf ¶
func Warningf(format string, args ...interface{})
Warningf logs a message at level Warn on the standard logger.
func Warningln ¶
func Warningln(args ...interface{})
Warningln logs a message at level Warn on the standard logger.
Types ¶
type Fields ¶
type Fields map[string]interface{}
Fields is used as key-value pairs for structured logging
type Logger ¶
type Logger interface { Debug(...interface{}) Debugln(...interface{}) Debugf(string, ...interface{}) Debugw(string, Fields) Info(...interface{}) Infoln(...interface{}) Infof(string, ...interface{}) Infow(string, Fields) Warn(...interface{}) Warnln(...interface{}) Warnf(string, ...interface{}) Warnw(string, Fields) Error(...interface{}) Errorln(...interface{}) Errorf(string, ...interface{}) Errorw(string, Fields) Panic(...interface{}) Panicln(...interface{}) Panicf(string, ...interface{}) Panicw(string, Fields) Fatal(...interface{}) Fatalln(...interface{}) Fatalf(string, ...interface{}) Fatalw(string, Fields) With(Fields) Logger // The following are added to be able to use this logger as a gRPC LoggerV2 if needed // Warning(...interface{}) Warningln(...interface{}) Warningf(string, ...interface{}) // V reports whether verbosity level l is at least the requested verbose level. V(l int) bool }
Logger represents an abstract logging interface. Any logging implementation used will need to abide by this interface
func AddPackage ¶
func AddPackage(outputType string, level int, defaultFields Fields, pkgNames ...string) (Logger, error)
AddPackage registers a package to the log map. Each package gets its own logger which allows its config (loglevel) to be changed dynamically without interacting with the other packages. outputType is JSON, level is the lowest level log to output with this logger and defaultFields is a map of key-value pairs to always add to the output. Note: AddPackage also returns a reference to the actual logger. If a calling package uses this reference directly instead of using the publicly available functions in this log package then a number of functionalities will not be available to it, notably log tracing with filename.functionname.linenumber annotation.
pkgNames parameter should be used for testing only as this function detects the caller's package.
func SetDefaultLogger ¶
SetLogger needs to be invoked before the logger API can be invoked. This function initialize the default logger (zap's sugaredlogger)
func UpdateLogger ¶
UpdateLogger deletes the logger associated with a caller's package and creates a new logger with the defaultFields. If a calling package is holding on to a Logger reference obtained from AddPackage invocation, then that package needs to invoke UpdateLogger if it needs to make changes to the default fields and obtain a new logger reference