Documentation
¶
Index ¶
- Constants
- func ConfigureFromEnv()
- func Debug(message string)
- func DebugC(component string, message string)
- func DebugCF(component string, message string, fields map[string]any)
- func DebugF(message string, fields map[string]any)
- func Debugf(message string, ss ...any)
- func DisableConsole()
- func DisableFileLogging()
- func EnableConsole()
- func EnableFileLogging(filePath string) error
- func Error(message string)
- func ErrorC(component string, message string)
- func ErrorCF(component string, message string, fields map[string]any)
- func ErrorF(message string, fields map[string]any)
- func Errorf(message string, ss ...any)
- func Fatal(message string)
- func FatalC(component string, message string)
- func FatalCF(component string, message string, fields map[string]any)
- func FatalF(message string, fields map[string]any)
- func Fatalf(message string, ss ...any)
- func Info(message string)
- func InfoC(component string, message string)
- func InfoCF(component string, message string, fields map[string]any)
- func InfoF(message string, fields map[string]any)
- func Infof(message string, ss ...any)
- func InitPanic(filePath string) (func(), error)
- func RecoverPanicNoExit(err any)
- func Redact(s string) string
- func RegisterSecret(value string)
- func SetConsoleLevel(level LogLevel)
- func SetConsoleOutput(w io.Writer)
- func SetLevel(level LogLevel)
- func SetLevelFromString(s string)
- func SetRedaction(enabled bool)
- func SetRotation(maxSizeMB, maxFiles int)
- func Warn(message string)
- func WarnC(component string, message string)
- func WarnCF(component string, message string, fields map[string]any)
- func WarnF(message string, fields map[string]any)
- func Warnf(message string, ss ...any)
- type LogLevel
Constants ¶
const ( DEBUG = zerolog.DebugLevel INFO = zerolog.InfoLevel WARN = zerolog.WarnLevel ERROR = zerolog.ErrorLevel FATAL = zerolog.FatalLevel Component = "component" )
Variables ¶
This section is empty.
Functions ¶
func ConfigureFromEnv ¶
func ConfigureFromEnv()
func DisableConsole ¶
func DisableConsole()
func DisableFileLogging ¶
func DisableFileLogging()
func EnableConsole ¶
func EnableConsole()
func EnableFileLogging ¶
EnableFileLogging also writes the log to filePath, which is created owner only (0600, in a 0700 directory when the directory is new) and rotated by size (see SetRotation). Calling it again moves file logging to filePath: the new file is opened before the old one is closed, so a file that cannot be opened leaves the current one in place.
func InitPanic ¶
InitPanic opens the panic log at filePath, owner only, and sends the process's stderr there. It returns the function a deferred call runs to record a panic and exit, or an error when the log cannot be opened.
func RecoverPanicNoExit ¶
func RecoverPanicNoExit(err any)
func Redact ¶
Redact returns s with what a log line must not show masked: every value registered with RegisterSecret, the user info of URLs, the values of query parameters named like keys, tokens, secrets and passwords, and the secret part of Telegram-style bot tokens. It returns s unchanged while redaction is off.
func RegisterSecret ¶
func RegisterSecret(value string)
RegisterSecret adds value, such as an API key or a token, to the values masked in every log line. Other packages feed it the secrets they load. Values shorter than four bytes are ignored.
func SetConsoleLevel ¶
func SetConsoleLevel(level LogLevel)
func SetConsoleOutput ¶
SetConsoleOutput sends the console log to w instead of stdout, for a command whose stdout another program parses. A disabled console stays disabled.
func SetLevelFromString ¶
func SetLevelFromString(s string)
SetLevelFromString sets the log level from a string value. If the string is empty or not a recognized level name, the current level is kept.
func SetRedaction ¶
func SetRedaction(enabled bool)
SetRedaction turns log redaction on or off. It is on until turned off.
func SetRotation ¶
func SetRotation(maxSizeMB, maxFiles int)
SetRotation sets when the log file rotates: once it would grow past maxSizeMB megabytes, it becomes <file>.1, an older <file>.1 becomes <file>.2 and so on, keeping maxFiles files in all, the current one included. A value of zero or less selects the default (10 MB, 5 files). It applies to the file being written at once.