logger

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

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

Go to latest
Published: Jul 1, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logger is a simple package for level based logging

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level uint

Level is a type used to represent a logging level

const (
	FATAL Level = iota
	ERROR
	WARNING
	INFO
	DEBUG
	TRACE
)

type Logger

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

Logger represents the state of a level based logger

func Global

func Global() *Logger

Global returns the reference of the global logger

func NewLogger

func NewLogger(lvl Level) *Logger

NewLogger creates a new Logger with given level

func (*Logger) Debug

func (lggr *Logger) Debug(msg string)

Debug is used to log diagnostic information

func (*Logger) Error

func (lggr *Logger) Error(msg string)

Error is used when there is a failure of some important part of the code

func (*Logger) Fatal

func (lggr *Logger) Fatal(msg string)

Fatal is used when somthing catastrophic happend. It also calls os.Exit(1)

func (*Logger) GetLevel

func (lggr *Logger) GetLevel() Level

GetLevel return the current logging level

func (*Logger) Info

func (lggr *Logger) Info(msg string)

Info is used to log normal behavior

func (*Logger) SetLevel

func (lggr *Logger) SetLevel(lvl Level)

SetLevel sets the logging level to lvl. Once set, all the logging calls with level higher than the current level are discarded. Levels from lowest to highest are: FATAL, ERROR, WARNING, INFO, DEBUG, TRACE By default the level log level is set to INFO

func (*Logger) Trace

func (lggr *Logger) Trace(msg string)

Trace is used to log diagnostic information that could flood the output of the program

func (*Logger) Warning

func (lggr *Logger) Warning(msg string)

Warning is used when an anomaly that could potentially cause problems is detected

Jump to

Keyboard shortcuts

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