logger

package
v0.0.0-...-a3532f1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 4 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrettyWriter

func PrettyWriter() io.Writer

PrettyWriter returns a ConsoleWriter which writes logs in a human-readable format.

Types

type Logger

type Logger interface {
	Trace(msg string, fields ...map[string]interface{})
	Debug(msg string, fields ...map[string]interface{})
	Info(msg string, fields ...map[string]interface{})
	Warn(msg string, fields ...map[string]interface{})
	Error(msg string, fields ...map[string]interface{})
}

Logger defines the interface for a logger.

func New

func New(opts ...Option) Logger

New creates a new Logger based on provided Options.

func NoOp

func NoOp() Logger

NoOp returns a no-operation Logger which doesn't perform any logging operations.

type Option

type Option func(*Options)

Option defines a function which sets an option on the Options struct.

func WithHook

func WithHook(hook zerolog.Hook) Option

WithHook adds a hook to the logger.

func WithLogLevel

func WithLogLevel(level string) Option

WithLogLevel sets the log level on the Options struct.

func WithWriters

func WithWriters(writers ...io.Writer) Option

WithWriter sets the writer on the Options struct.

type Options

type Options struct {
	LogLevel string
	Writers  []io.Writer
	Hooks    []zerolog.Hook
}

Options struct defines the logger options. LogLevel sets the level of logs to show (trace, debug, info, warn, error). Writer sets the writer to write logs to. Hooks sets the hooks to be used by the logger.

Jump to

Keyboard shortcuts

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