Documentation ¶
Overview ¶
package clog is used to do contextual logging with a global logger.
Index ¶
- func AddHandler(handler log.Handler)
- func CallerInfoHandler(h log.Handler) log.Handler
- func ContextForRetries(ctx context.Context, activity string) context.Context
- func ContextWithCallValue(ctx context.Context, key string) context.Context
- func ContextWithCloudType(ctx context.Context, key string) context.Context
- func ContextWithFileHandler(ctx context.Context, path, lvl string) (context.Context, error)
- func ContextWithJobKey(ctx context.Context, key string) context.Context
- func ContextWithLogHandler(ctx context.Context, key log15.Handler) context.Context
- func ContextWithRetryNum(ctx context.Context, retrynum int) context.Context
- func ContextWithSchedulerType(ctx context.Context, key string) context.Context
- func ContextWithServerFlavor(ctx context.Context, key string) context.Context
- func ContextWithServerID(ctx context.Context, key string) context.Context
- func CreateFileHandlerAtLevel(path, lvl string) (log.Handler, error)
- func Crit(ctx context.Context, msg string, args ...interface{})
- func Debug(ctx context.Context, msg string, args ...interface{})
- func Error(ctx context.Context, msg string, args ...interface{})
- func Fatal(ctx context.Context, msg string, args ...interface{})
- func GetHandler() log.Handler
- func Info(ctx context.Context, msg string, args ...interface{})
- func ToBufferAtLevel(lvl string) *bytes.Buffer
- func ToDefault()
- func ToDefaultAtLevel(lvl string)
- func ToFileAtLevel(path, lvl string) error
- func ToHandlerAtLevel(outputHandler log.Handler, lvl string)
- func UniqueID() string
- func Warn(ctx context.Context, msg string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHandler ¶ added in v0.2.4
AddHandler adds the given log15 handler to global logger.
func CallerInfoHandler ¶ added in v0.4.0
CallerInfoHandler returns a Handler that, at the Debug, Warn and Error levels, adds the file and line number of the calling function to the context with key "caller". At the Crit levels it instead adds a stack trace to the context with key "stack". The stack trace is formatted as a space separated list of call sites inside matching []'s. The most recent call site is listed first.
func ContextForRetries ¶
ContextForRetries returns a context which knows a new unique retryset ID, as well as the given retryactivity.
func ContextWithCallValue ¶ added in v0.2.5
ContextWithCallValue returns a context which knows the given call value.
func ContextWithCloudType ¶ added in v0.2.4
ContextWithCloudType returns a context which knows the given cloud type.
func ContextWithFileHandler ¶ added in v0.3.0
ContextWithFileHandler returns a context that will log to the given file at the given level.
func ContextWithJobKey ¶ added in v0.2.4
ContextWithJobKey returns a context which knows the given key.
func ContextWithLogHandler ¶ added in v0.3.0
ContextWithLogHandler returns a context which knows the given log handler.
func ContextWithRetryNum ¶
ContextWithRetryNum returns a context which knows the given retrynum.
func ContextWithSchedulerType ¶ added in v0.2.4
ContextWithSchedulerType returns a context which knows the given scheduler type.
func ContextWithServerFlavor ¶ added in v0.2.5
ContextWithServerFlavor returns a context which knows the given server flavour.
func ContextWithServerID ¶ added in v0.2.4
ContextWithServerID returns a context which knows the given id.
func CreateFileHandlerAtLevel ¶ added in v0.2.4
CreateFileHandlerAtLevel returns a log15 file handler at the given level.
func Crit ¶
Crit logs the given message with context and args to the global logger at the error level. A stack trace is included.
func Debug ¶
Debug logs the given message with context and args to the global logger at the debug level. Caller info is included.
func Error ¶
Error logs the given message with context and args to the global logger at the error level. Caller info is included.
func Fatal ¶ added in v0.2.1
Fatal logs the given message with context and args to the global logger at the error level before exiting. 'fatal' is set true in stack trace.
If the WR_FATAL_EXIT_TEST environment variable is set to 1, we don't actually exit.
func GetHandler ¶ added in v0.2.4
GetHandler returns the global logger handler used for all logging.
func Info ¶
Info logs the given message with context and args to the global logger at the info level.
func ToBufferAtLevel ¶
ToBufferAtLevel sets the global logger to log to the returned bytes.Buffer at the given level.
func ToDefault ¶
func ToDefault()
ToDefault sets the global logger to log to STDERR at the "warn" level.
func ToDefaultAtLevel ¶ added in v0.2.2
func ToDefaultAtLevel(lvl string)
ToDefaultAtLevel sets the global logger to log to STDERR at the given level.
func ToFileAtLevel ¶
ToFileAtLevel sets the global logger to log to a file at the given path and at the given level.
func ToHandlerAtLevel ¶ added in v0.2.3
ToHandlerAtLevel sets the default logger to a given custom handler at the given level. Eg. to log to syslog ... handler, _ := log15.SyslogHandler(syslog.LOG_USER, "wrrunner", log15.LogfmtFormat()) clog.ToHandlerAtLevel(handler, "info") ...
Types ¶
This section is empty.