logger

package
v0.0.0-...-0c481e8 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLevel

func SetLevel(level Level)

SetLevel is mirror logger set level

func SetLevelStr

func SetLevelStr(level string)

SetLevelStr will transform string to level and set

Types

type Level

type Level struct {
	Code  uint8
	Name  string
	Short string
}

Level is logging level

var (
	// DEBUG is lowest level in logging
	DEBUG Level = Level{
		Code:  uint8(5),
		Name:  "Debug",
		Short: "DBG",
	}

	// INFO is common message
	INFO Level = Level{
		Code:  uint8(3),
		Name:  "Info",
		Short: "INF",
	}

	// WARN is a calm error message
	WARN Level = Level{
		Code:  uint8(2),
		Name:  "Warn",
		Short: "WRN",
	}

	// ERROR is a critical error message
	ERROR Level = Level{
		Code:  uint8(1),
		Name:  "Error",
		Short: "ERR",
	}

	// SILENT is a special level for mute all logging
	SILENT Level = Level{
		Code:  uint8(0),
		Name:  "Silent",
		Short: "",
	}
)

func (Level) String

func (l Level) String() string

type Logger

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

Logger is logging object

func Get

func Get() *Logger

Get will return singleton logger object

func (*Logger) CheckLevel

func (l *Logger) CheckLevel(level Level) bool

CheckLevel is input level should be log or not

func (*Logger) Debug

func (l *Logger) Debug(key int, format string, params ...interface{})

Debug is logging as debug message

func (*Logger) Error

func (l *Logger) Error(key int, err error)

Error is logging as error message

func (*Logger) Format

func (l *Logger) Format(format string, params ...interface{})

Format will do formatting message before log

func (*Logger) Info

func (l *Logger) Info(key int, format string, params ...interface{})

Info is logging as info message

func (*Logger) IsDebug

func (l *Logger) IsDebug() bool

IsDebug will return true if on debug mode

func (*Logger) Log

func (l *Logger) Log(msg string)

Log will logging data without any formatting

func (*Logger) Newline

func (l *Logger) Newline()

Newline will go to newline

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel will update current logging level

func (*Logger) Warn

func (l *Logger) Warn(key int, format string, params ...interface{})

Warn is logging as warn message

Jump to

Keyboard shortcuts

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