clog

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 9 Imported by: 9

Documentation

Overview

package clog is used to do contextual logging with a global logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandler added in v0.2.4

func AddHandler(handler log.Handler)

AddHandler adds the given log15 handler to global logger.

func CallerInfoHandler added in v0.4.0

func CallerInfoHandler(h log.Handler) log.Handler

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

func ContextForRetries(ctx context.Context, activity string) context.Context

ContextForRetries returns a context which knows a new unique retryset ID, as well as the given retryactivity.

func ContextWithCallValue added in v0.2.5

func ContextWithCallValue(ctx context.Context, key string) context.Context

ContextWithCallValue returns a context which knows the given call value.

func ContextWithCloudType added in v0.2.4

func ContextWithCloudType(ctx context.Context, key string) context.Context

ContextWithCloudType returns a context which knows the given cloud type.

func ContextWithFileHandler added in v0.3.0

func ContextWithFileHandler(ctx context.Context, path, lvl string) (context.Context, error)

ContextWithFileHandler returns a context that will log to the given file at the given level.

func ContextWithJobKey added in v0.2.4

func ContextWithJobKey(ctx context.Context, key string) context.Context

ContextWithJobKey returns a context which knows the given key.

func ContextWithLogHandler added in v0.3.0

func ContextWithLogHandler(ctx context.Context, key log15.Handler) context.Context

ContextWithLogHandler returns a context which knows the given log handler.

func ContextWithRetryNum

func ContextWithRetryNum(ctx context.Context, retrynum int) context.Context

ContextWithRetryNum returns a context which knows the given retrynum.

func ContextWithSchedulerType added in v0.2.4

func ContextWithSchedulerType(ctx context.Context, key string) context.Context

ContextWithSchedulerType returns a context which knows the given scheduler type.

func ContextWithServerFlavor added in v0.2.5

func ContextWithServerFlavor(ctx context.Context, key string) context.Context

ContextWithServerFlavor returns a context which knows the given server flavour.

func ContextWithServerID added in v0.2.4

func ContextWithServerID(ctx context.Context, key string) context.Context

ContextWithServerID returns a context which knows the given id.

func CreateFileHandlerAtLevel added in v0.2.4

func CreateFileHandlerAtLevel(path, lvl string) (log.Handler, error)

CreateFileHandlerAtLevel returns a log15 file handler at the given level.

func Crit

func Crit(ctx context.Context, msg string, args ...interface{})

Crit logs the given message with context and args to the global logger at the error level. A stack trace is included.

func Debug

func Debug(ctx context.Context, msg string, args ...interface{})

Debug logs the given message with context and args to the global logger at the debug level. Caller info is included.

func Error

func Error(ctx context.Context, msg string, args ...interface{})

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

func Fatal(ctx context.Context, msg string, args ...interface{})

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

func GetHandler() log.Handler

GetHandler returns the global logger handler used for all logging.

func Info

func Info(ctx context.Context, msg string, args ...interface{})

Info logs the given message with context and args to the global logger at the info level.

func ToBufferAtLevel

func ToBufferAtLevel(lvl string) *bytes.Buffer

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

func ToFileAtLevel(path, lvl string) error

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

func ToHandlerAtLevel(outputHandler log.Handler, lvl string)

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") ...

func UniqueID

func UniqueID() string

UniqueID returns a globally unique 20 character string that is safe for transport, featuring the characters [0-9a-v]{20}.

func Warn

func Warn(ctx context.Context, msg string, args ...interface{})

Warn logs the given message with context and args to the global logger at the warn level. Caller info is included.

Types

This section is empty.

Jump to

Keyboard shortcuts

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