log

package
Version: v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRequestID

func AddRequestID(ctx context.Context, fields loggo.Fields) loggo.Fields

AddRequestID adds the request Id to fields if one is there

func F

func F(args ...interface{}) (res map[string]interface{})

F generates a map using a key-value pairs as arguments for example, if given arguments are "key" and 1 will return map[string]interface{}{"key": 1} PS: will not add key if the value is missing

func GetFields

func GetFields(ctx context.Context) (fields loggo.Fields)

GetFields get fields using a context

func NoCodeFormat

func NoCodeFormat(entry loggo.Entry) string

NoCodeFormat will remove the code reference from msg

func SetLevel

func SetLevel(level Level)

SetLevel Sets logging levels

Types

type BasicLogger

type BasicLogger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

BasicLogger basic logger interface

type EmptyLogger

type EmptyLogger struct{}

EmptyLogger empty logger (does nothing)

func (EmptyLogger) Debug

func (EmptyLogger) Debug(format string, args ...interface{})

Debug nothing

func (EmptyLogger) Debugf

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

Debugf nothing

func (EmptyLogger) Error

func (EmptyLogger) Error(format string, args ...interface{})

Error nothing

func (EmptyLogger) Errorf

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

Errorf nothing

func (EmptyLogger) Info

func (EmptyLogger) Info(format string, args ...interface{})

Info nothing

func (EmptyLogger) Infof

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

Infof nothing

func (EmptyLogger) StCritical

func (EmptyLogger) StCritical(message string, fields loggo.Fields)

StCritical nothing

func (EmptyLogger) StDebug

func (EmptyLogger) StDebug(message string, fields loggo.Fields)

StDebug nothing

func (EmptyLogger) StError

func (EmptyLogger) StError(message string, fields loggo.Fields)

StError nothing

func (EmptyLogger) StInfo

func (EmptyLogger) StInfo(message string, fields loggo.Fields)

StInfo nothing

func (EmptyLogger) StTrace

func (EmptyLogger) StTrace(message string, fields loggo.Fields)

StTrace nothing

func (EmptyLogger) StWarning

func (EmptyLogger) StWarning(message string, fields loggo.Fields)

StWarning nothing

func (EmptyLogger) Trace

func (EmptyLogger) Trace(format string, args ...interface{})

Trace nothing

func (EmptyLogger) Tracef

func (EmptyLogger) Tracef(format string, args ...interface{})

Tracef nothing

func (EmptyLogger) Warning

func (EmptyLogger) Warning(format string, args ...interface{})

Warning nothing

func (EmptyLogger) Warningf

func (EmptyLogger) Warningf(format string, args ...interface{})

Warningf nothing

type Level

type Level int

Level defines log levels

const (
	// LevelTrace prints all tracing and up
	LevelTrace Level = iota
	// LevelDebug prints all messages
	LevelDebug
	// LevelInfo prints only info or higher
	LevelInfo
	// LevelError prints only error messages
	LevelError
)

type Logger

type Logger interface {
	StandardLogger
	StructuredLogger
	StLogger
}

Logger interface to define a logger entity

func GetSafe

func GetSafe(logger Logger) Logger

GetSafe will verify if given logger is initiated and will return an empty logger when it is not to make log calls safe

func NewLogger

func NewLogger(packageName string, size ...int) Logger

NewLogger constructs a new logger for package @param: packageName stands for the package of your logger @param: depth given one integer will set the depth in which will find during runtime the file and line number recommended to use 3 as a number (only the first integer will be used)

func NewNoCodeLogger

func NewNoCodeLogger(name string, size ...int) Logger

NewNoCodeLogger will not print file

type StLogger

type StLogger interface {
	StCritical(message string, fields loggo.Fields)
	StError(message string, fields loggo.Fields)
	StWarning(message string, fields loggo.Fields)
	StInfo(message string, fields loggo.Fields)
	StDebug(message string, fields loggo.Fields)
	StTrace(message string, fields loggo.Fields)
}

StLogger St logging functions for using with loggo.Fields

type StandardLogger

type StandardLogger interface {
	Tracef(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

StandardLogger stan

func NewStandardLogger

func NewStandardLogger(packageName string, depth ...int) StandardLogger

NewStandardLogger constructs a standard logger

type StructuredLogger

type StructuredLogger interface {
	Trace(msg string, keyValues ...interface{})
	Debug(msg string, keyValues ...interface{})
	Info(msg string, keyValues ...interface{})
	Warning(msg string, keyValues ...interface{})
	Error(msg string, keyValues ...interface{})
}

StructuredLogger simplified structured logger signature

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL