logger

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug

Log a debug message with args.

func Error

func Error(args ...interface{})

Error

Log a error message with args.

func Fatal

func Fatal(args ...interface{})

Fatal

Log a fatal message with args.

func Info

func Info(args ...interface{})

Info

Log a info message with args.

func Init

func Init(env *environment.Env)

Init will set up the logger and set logging levels dependant on environment variables.

func Middleware

func Middleware() gin.HandlerFunc

Middleware

Middleware is the handler function for logging system application messages, if there was an error or message set, it will be retrieved from the context. Status codes between 200 and 400 will be logged as info, otherwise an error.

func Panic

func Panic(args ...interface{})

Panic

Log a panic message with args.

func SetOutput

func SetOutput(writer io.Writer)

SetOutput

Set the output of the logger to an io.Writer, useful for testing.

func Trace

func Trace(args ...interface{})

Trace

Log a trace message with args.

func Warn

func Warn(args ...interface{})

Warn

Log a warn message with args.

func WithError

func WithError(err interface{}) *logrus.Entry

WithError

Logs with a Verbis error.

func WithField

func WithField(key string, value interface{}) *logrus.Entry

WithField

Logs with field, sets a new map containing "fields"

func WithFields

func WithFields(fields logrus.Fields) *logrus.Entry

WithFields

Logs with fields, sets a new map containing "fields"

Types

type Formatter

type Formatter struct {
	Colours         bool
	TimestampFormat string
	Debug           bool
	// contains filtered or unexported fields
}

Formatter implements logrus.Formatter interface.

func (*Formatter) Error

func (f *Formatter) Error()

Error

Prints out the error if there is one set. If the error is nil, nothing will be printed.

func (*Formatter) Fields

func (f *Formatter) Fields()

Fields

Prints the entry fields

func (*Formatter) Format

func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error)

Format

Format building log message.

func (*Formatter) HasError

func (f *Formatter) HasError() (interface{}, bool)

HasError

Determines if a verbis error has been logged.

func (*Formatter) IP

func (f *Formatter) IP()

IP

Prints the IP address if there is any.

func (*Formatter) Level

func (f *Formatter) Level()

Level

Prints the entry level of the log entry in uppercase.

func (*Formatter) Message

func (f *Formatter) Message()

Message

Prints the entry message if there is obe set.

func (*Formatter) Method

func (f *Formatter) Method()

Method

Prints the entry request method if there is one set.

func (*Formatter) StatusCode

func (f *Formatter) StatusCode()

StatusCode

Prints the status code of the request, if there is none set the log is config and "VRB" will be printed.

func (*Formatter) Time

func (f *Formatter) Time()

Time

Prints the timestamp for the log, if no format is set on the formatter, time.StampMilli will be used.

func (*Formatter) URL

func (f *Formatter) URL()

URL

Prints the entry request url if there is one set.

type WriterHook

type WriterHook struct {
	// The io.Writer, this can be stdout or stderr.
	Writer io.Writer
	// The slice of log levels the writer can too.
	LogLevels []logrus.Level
}

WriterHook is a hook that writes logs of specified LogLevels to specified Writer.

func (*WriterHook) Fire

func (hook *WriterHook) Fire(entry *logrus.Entry) error

Fire

Fire will be called when some logging function is called with current hook. It will format log entry to string and write it to appropriate writer

func (*WriterHook) Levels

func (hook *WriterHook) Levels() []logrus.Level

Levels

Define on which log levels this hook would trigger

Jump to

Keyboard shortcuts

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