log

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package log implements convenience functionality on top of the Go kit logging package github.com/go-kit/log.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger wraps a Logger from package github.com/go-kit/log to provide a more convenient way to log with a particular level. Note that Logger still implements the Logger interface from github.com/go-kit/log.

func DefaultJSONLogger

func DefaultJSONLogger(options ...Option) *Logger

Default logger that encodes log events as a single json object and writes them to stdout.

There are four different log levels: error/warn/info/debug (in descending order of severity). An option can be passed to filter out log messages below a certain level. E.g. if AllowInfo is passed, only log messages with level info/warn/error or without a level will be logged. By default only log messages with or above level info are logged.

func (Logger) Debug

func (l Logger) Debug() Logger

Returns a logger that logs with level Debug.

func (Logger) Error

func (l Logger) Error() Logger

Returns a logger that logs with level Error.

func (Logger) Info

func (l Logger) Info() Logger

Returns a logger that logs with level Info.

func (Logger) Log

func (l Logger) Log(keyvals ...interface{}) error

func (Logger) Warn

func (l Logger) Warn() Logger

Returns a logger that logs with level Warn.

func (Logger) With

func (l Logger) With(keyvals ...interface{}) Logger

Returns a logger that adds the given key-value pairs to every log message.

type Option

type Option string
const AllowDebug Option = "allowDebug"
const AllowError Option = "allowError"
const AllowInfo Option = "allowInfo"
const AllowWarn Option = "allowWarn"
const PrettyPrint Option = "prettyPrint"

Pretty print JSON log events, i.e. as multiple indented lines. Useful for development and testing.

Jump to

Keyboard shortcuts

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