xlog

package
v0.0.0-...-5a98790 Latest Latest
Warning

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

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

Documentation

Overview

Package xlog defines a standard logger for the application.

It uses structured logging thanks to https://github.com/sirupsen/logrus.

All messages have at least two fields:

A "trace" field which helps to identify messages belonging to the same context.

An "op" field which helps to identify the logical operation associated with the message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Levels

func Levels() []string

Levels returns a slice of string with all severities.

Types

type Level

type Level string

Level helps setting the severity of the messages displayed.

const (
	// DebugLevel is the lowest level.
	DebugLevel Level = "DEBUG"
	// InfoLevel is the intermediate level.
	InfoLevel Level = "INFO"
	// ErrorLevel is the highest level.
	ErrorLevel Level = "ERROR"
)

func MustParseLevel

func MustParseLevel(level string) Level

MustParseLevel returns the Level corresponding to given string.

It panics if no correspondence.

type Logger

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

Logger enforces specific log message formats.

func New

func New(level Level, trace string) Logger

New returns a xlog.Logger.

func (Logger) DebugOp

func (l Logger) DebugOp(op, message string)

DebugOp logs a debug message for given logical operation.

func (Logger) DebugOpf

func (l Logger) DebugOpf(op, format string, args ...interface{})

DebugOpf logs a debug message for given logical operation and format.

func (Logger) ErrorOp

func (l Logger) ErrorOp(op string, err error)

ErrorOp logs an error for given logical operation.

func (Logger) ErrorOpf

func (l Logger) ErrorOpf(op, format string, args ...interface{})

ErrorOpf logs an error message for given logical operation and format.

func (Logger) FatalOp

func (l Logger) FatalOp(op string, err error)

FatalOp logs an error for given logical operation and exit 1.

func (Logger) InfoOp

func (l Logger) InfoOp(op, message string)

InfoOp logs an info message for given logical operation.

func (Logger) InfoOpf

func (l Logger) InfoOpf(op, format string, args ...interface{})

InfoOpf logs an info message for given logical operation and format.

func (Logger) Level

func (l Logger) Level() Level

Level returns the current Level.

func (Logger) WithFields

func (l Logger) WithFields(fields map[string]interface{}) Logger

WithFields returns a new xlog.Logger with given fields.

Jump to

Keyboard shortcuts

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