logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build added in v1.0.0

func Build(
	service string,
	level log.Level,
	f log.Formatter,
	p log.Printer,
) log.Logger

Build builds a logger from the given formatter and printer

func New

func New(service string, config config.Tree) (log.Logger, error)

New creates a new logger

func StdOut added in v1.0.0

func StdOut(service string, level log.Level) (log.Logger, error)

StdOut creates a new logger that outputs logs in stdout

This function is useful when logger is being used in standalone mode

Types

type Config

type Config struct {
	Level string `toml:"level"`
}

Config contains all log-related configuration

type Logger

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

Logger is the key struct of the log package. It is the part that links the log formatter to the log printer

func (*Logger) AddCalldepth

func (l *Logger) AddCalldepth(n int) log.Logger

AddCalldepth clones the logger and changes the call depth

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Error

func (l *Logger) Error(tag, msg string, fields ...log.Field)

Error creates a trace log line. Error level logs need immediate attention The 2AM rule applies here, which means that if you are on call, this log line will wake you up at 2AM

func (*Logger) Trace

func (l *Logger) Trace(tag, msg string, fields ...log.Field)

Trace creates a trace log line. Trace level logs are to follow the code executio step by step

func (*Logger) Warning

func (l *Logger) Warning(tag, msg string, fields ...log.Field)

Warning creates a trace log line. Warning level logs are meant to draw attention above a certain threshold

func (*Logger) With

func (l *Logger) With(fields ...log.Field) log.Logger

With adds the given fields to a cloned logger

Jump to

Keyboard shortcuts

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