log

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Debug has verbose message
	Debug = "debug"
	//Info is default log level
	Info = "info"
	//Warn is for logging messages about possible issues
	Warn = "warn"
	//WithError is for logging errors
	Error = "error"
	// Panic log a message and panic.
	Panic = "panic"
	//Fatal is for logging fatal messages. The system shuts down after logging the message.
	Fatal = "fatal"
)
View Source
const (
	//TimeKey is a logger key for time
	TimeKey = "ts"
	//MessageKey is a logger key for message
	MessageKey = "msg"
	//LevelKey is a logger key for logging level
	LevelKey = "level"
	//CallerKey ia a logger key for caller/invoking function
	CallerKey = "caller"
	// ErrorKey is a logger key for message
	ErrorKey = "err"
)
View Source
const (
	// LogFormatJson is a format for json logging
	LogFormatJson = "json"
	// LogFormatPlain is a format for plain-text logging
	LogFormatPlain = "plain"
	// LogFormatLogfmt is a format for logfmt logging
	LogFormatLogfmt = "logfmt"
)

Variables

View Source
var DefaultLogger = NewDefaultLogger()

Functions

func Printf

func Printf(format string, args ...interface{})

Types

type Configuration

type Configuration struct {
	LogFormat     string
	LogLevel      string
	LogFieldNames LogFieldNames
}

Configuration stores the config for the logger

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type LogFieldNames

type LogFieldNames struct {
	Time    string
	Message string
	Level   string
	Caller  string
	Error   string
}

type Logger

type Logger interface {
	Printf(format string, args ...interface{})

	Debugf(format string, args ...interface{})

	Infof(format string, args ...interface{})

	Warnf(format string, args ...interface{})

	Errorf(format string, args ...interface{})

	Panicf(format string, args ...interface{})

	Fatalf(format string, args ...interface{})

	WithFields(keyValues Fields) Logger

	WithField(key, value string) Logger

	WithError(err error) Logger

	IsDebug() bool

	IsInfo() bool

	IsWarn() bool

	IsError() bool

	IsPanic() bool

	IsFatal() bool
}

Logger is our contract for the logger

func NewDefaultLogger

func NewDefaultLogger() Logger

NewDefaultLogger returns an instance of logger with default parameters

func NewLogger

func NewLogger(config Configuration) Logger

NewLogger returns an instance of logger

Jump to

Keyboard shortcuts

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