Categorygithub.com/savsgio/go-logger/v4
modulepackage
4.2.6
Repository: https://github.com/savsgio/go-logger.git
Documentation: pkg.go.dev

# README

go-logger

Test status Coverage Status Go Report Card GoDev GitHub release

Fast, lightweight, customizable and structured logger for Go.

Install

go get github.com/savsgio/go-logger/v4

Supported Go versions:

  • 1.22.x
  • 1.21.x,
  • 1.20.x
  • 1.19.x
  • 1.18.x
  • 1.17.x

Levels:

LevelCode (constant)Value (str)
Printlogger.PRINT
Paniclogger.PANICpanic / PANIC
Fatallogger.FATALfatal / FATAL
Errorlogger.ERRORerror / ERROR
Warninglogger.WARNINGwarning / WARNING
Infologger.INFOinfo / INFO
Debuglogger.DEBUGdebug / DEBUG
Tracelogger.TRACEtrace / TRACE

NOTE: The default level of standard logger is INFO.

Encoders:

  • Text
  • JSON
  • Custom (your own encoder).

NOTE: The default encoder of standard logger is text.

Contributing

Feel free to contribute it or fork me... :wink:

# Functions

AcquireBuffer returns a buffer instance from pool.
AddHook registers the given hook to the standard logger.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
IsLevelEnabled checks if the given level is enabled on the standard logger.
New creates a new Logger.
NewBuffer returns a new buffer.
NewEncoderJSON creates a new json encoder.
NewEncoderText creates a new text encoder.
No description provided by the author
No description provided by the author
ParseLevel returns the Level constant from the given level string.
No description provided by the author
No description provided by the author
ReleaseBuffer puts the given buffer in the pool after it is reset.
SetEncoder sets the encoder to the standard logger.
SetFields sets the fields to the standard logger.
SetFlags sets the output flags to the standard logger.
SetLevel sets the level to the standard logger.
SetOutput sets the output to the standard logger.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WithFields returns a copy of the standard logger with the given fields.

# Constants

Logger levels.
Logger levels.
Logger levels.
Logger levels.
Logger flags.
Logger flags.
Logger flags.
Logger flags.
Logger flags.
Logger flags.
Logger flags.
Logger levels.
Logger levels.
Logger timestamp formats.
Logger timestamp formats.
Logger levels.
Logger levels.

# Variables

ErrEmptyHookLevels is the empty hook levels error.
ErrInvalidLevel is the invalid level error.

# Structs

Buffer provides the byte buffer used by encoders to encode the output.
Config is the logger configuration.
EncoderBase is the base of encoders.
EncoderJSON is the json encoder.
EncoderJSONConfig is the configuration of json encoder.
EncoderText is the text enconder.
EncoderTextConfig is the configuration of text encoder.
EnconderJSONFieldMap defines name of keys.
Entry
Entry collects all the information for the output.
Field type.
Logger type.

# Interfaces

Encoder represents the encoders contract.
Hook represents a extended functionality that will be fired when logging.

# Type aliases

Flag type.
Level type.
TimestampFormat type.