logger

package
v2.0.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatStrings

func FormatStrings() []string

FormatStrings returns a slice of all logging formats as strings.

func LevelStrings

func LevelStrings() []string

LevelStrings returns a slice of all logging levels as strings.

func New

func New(l Level, f Format) (*zap.Logger, error)

New creates new "zap" echoLogger with a small customization.

func NewRedisBridge

func NewRedisBridge(zap *zap.Logger) *redisBridge

NewRedisBridge creates instance that can ba used as a bridge between zap and redis client for logging.

Types

type Format

type Format uint8

A Format is a logging format.

const (
	ConsoleFormat Format = iota // useful for console output (for humans)
	JSONFormat                  // useful for logging aggregation systems (for robots)
)

func Formats

func Formats() []Format

Formats returns a slice of all logging formats.

func ParseFormat

func ParseFormat[T string | []byte](text T) (Format, error)

ParseFormat parses a format (case is ignored) based on the ASCII representation of the log format. If the provided ASCII representation is invalid an error is returned.

This is particularly useful when dealing with text input to configure log formats.

func (Format) String

func (f Format) String() string

String returns a lower-case ASCII representation of the log format.

type Level

type Level int8

A Level is a logging level.

const (
	DebugLevel Level = iota - 1
	InfoLevel        // default level (zero-value)
	WarnLevel
	ErrorLevel
	FatalLevel
)

func Levels

func Levels() []Level

Levels returns a slice of all logging levels.

func ParseLevel

func ParseLevel[T string | []byte](text T) (Level, error)

ParseLevel parses a level (case is ignored) based on the ASCII representation of the log level. If the provided ASCII representation is invalid an error is returned.

This is particularly useful when dealing with text input to configure log levels.

func (Level) String

func (l Level) String() string

String returns a lower-case ASCII representation of the log level.

Jump to

Keyboard shortcuts

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