zlog

package
v0.0.0-...-ec5e203 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Log everything for debugging in dev environment
	LevelDebug = "debug"
	// log informational messages e.g: server started, a service is connected...
	LevelInfo = "info"
	// log warning but not critical messages
	LevelWarn = "warn"
	// log errors and problems in the server
	LevelError = "error"
)

Variables

View Source
var Any = zap.Any
View Source
var Bool = zap.Bool
View Source
var Duration = zap.Duration
View Source
var Err = zap.Error
View Source
var Int = zap.Int
View Source
var Int16 = zap.Int16
View Source
var Int32 = zap.Int32
View Source
var Int64 = zap.Int64
View Source
var NamedErr = zap.NamedError
View Source
var Object = zap.Object
View Source
var String = zap.String
View Source
var Time = zap.Time
View Source
var Uint16 = zap.Uint16
View Source
var Uint32 = zap.Uint32
View Source
var Uint64 = zap.Uint64
View Source
var Uint8 = zap.Uint8

Functions

func InitGlobalLogger

func InitGlobalLogger(logger *Logger)

func RedirectStdLog

func RedirectStdLog(logger *Logger)

Types

type Field

type Field = zapcore.Field

Alias zap functions and expose them, so we don't have to include the logger evey where

type LogFunc

type LogFunc func(string, ...Field)
var Critical LogFunc = defaultCriticalLog
var Debug LogFunc = defaultDebugLog
var Error LogFunc = defaultErrorLog
var Info LogFunc = defaultInfoLog
var Warn LogFunc = defaultWarnLog

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(config *LoggerConfiguration) *Logger

func NewLoggerInstance

func NewLoggerInstance(lc *config.Log) *Logger

func (*Logger) ChangeLevels

func (l *Logger) ChangeLevels(config *LoggerConfiguration)

func (*Logger) Critical

func (l *Logger) Critical(message string, fields ...Field)

func (*Logger) Debug

func (l *Logger) Debug(message string, fields ...Field)

func (*Logger) Error

func (l *Logger) Error(message string, fields ...Field)

func (*Logger) Info

func (l *Logger) Info(message string, fields ...Field)

func (*Logger) SetConsoleLevel

func (l *Logger) SetConsoleLevel(level string)

func (*Logger) StdLog

func (l *Logger) StdLog(fields ...Field) *log.Logger

func (*Logger) StdLogAt

func (l *Logger) StdLogAt(level string, fields ...Field) (*log.Logger, error)

StdLogAt returns *log.Logger which writes to supplied zap logger at required level.

func (*Logger) StdLogWriter

func (l *Logger) StdLogWriter() io.Writer

StdLogWriter returns a writer that can be hooked up to the output of a golang standard logger anything written will be interpreted as log entries accordingly

func (*Logger) Warn

func (l *Logger) Warn(message string, fields ...Field)

func (*Logger) With

func (l *Logger) With(fields ...Field) *Logger

func (*Logger) WithCallerSkip

func (l *Logger) WithCallerSkip(skip int) *Logger

func (*Logger) WithRequest

func (l *Logger) WithRequest(fields ...Field) *Logger

type LoggerConfiguration

type LoggerConfiguration struct {
	EnableConsole bool
	ConsoleJson   bool
	ConsoleLevel  string
	EnableFile    bool
	FileJson      bool
	FileLevel     string
	FileLocation  string
}

Jump to

Keyboard shortcuts

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