logger

package
v0.0.0-...-bc1f52c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package logger implements a new logger based on the zap lib.

Index

Constants

This section is empty.

Variables

View Source
var LevelsMap = map[string]zapcore.Level{
	"EMERGENCY": zapcore.PanicLevel,
	"ALERT":     zapcore.FatalLevel,
	"CRITICAL":  zapcore.FatalLevel,
	"ERROR":     zapcore.ErrorLevel,
	"WARNING":   zapcore.WarnLevel,
	"NOTICE":    zapcore.InfoLevel,
	"INFO":      zapcore.InfoLevel,
	"DEBUG":     zapcore.DebugLevel,
}

LevelsMap is a map to Logrus log levels

Functions

func Init

func Init(cfg config.Log) *zap.Logger

func InitLight

func InitLight(cfg config.Log) *zap.Logger

Types

type GELFEncoder

type GELFEncoder struct {
	zapcore.Encoder
}

GELFEncoder is a gelf encoder. It will use an underlying json encoder to encode entries to the gelf format. See http://docs.graylog.org/en/2.4/pages/gelf.html.

func NewGELFEncoder

func NewGELFEncoder() *GELFEncoder

NewGELFEncoder instanciate a new GELFEncoder.

func (GELFEncoder) Clone

func (e GELFEncoder) Clone() zapcore.Encoder

Clone implements the encoder interface.

func (GELFEncoder) EncodeEntry

func (e GELFEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)

EncodeEntry escape the keys following the gelf spec, then the underlying encoder will encode the entry.

type Level

type Level zapcore.Level

Level implements the UnmarshalText Interface to be able to be load into the config. It is mainly used for parsing configuration with github.com/kelseyhightower/envconfig.

func (Level) String

func (l Level) String() string

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

func (*Level) UnmarshalText

func (l *Level) UnmarshalText(text []byte) error

UnmarshalText unmarshal a text to a level. Returns an error if no level match.

Jump to

Keyboard shortcuts

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