logger

package
v1.8.1-0...-ed8303a Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logger contains functions for a working with application logging.

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" logger with a small customization.

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