log

package
v2.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Log is global logger
	Log      *zap.Logger
	Sugar    *zap.SugaredLogger
	LogLevel Level
)

Functions

func Failure

func Failure(msg string)

func Init

func Init(l Level, timeFormat string, consoleFormat bool) error

Init initializes log by input parameters lvl - global log level: Debug(-1), Info(0), Warn(1), Error(2), DPanic(3), Panic(4), Fatal(5) timeFormat - custom time format for logger of empty string to use default

func Success

func Success(msg string)

Types

type Context

type Context map[string]interface{}

func (Context) Log

func (c Context) Log(msg string, lvl Level)

func (Context) NewError

func (c Context) NewError(err interface{}, lvl Level) ContextError

type ContextError

type ContextError interface {
	Error() string
	Log(int)
	Add(Context)
}

type Level

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

Level holds the logging level. It can be set either via integers [-1,,5] or via the associated string names: Debug(-1), Info(0), Warn(1), Error(2), DPanic(3), Panic(4), Fatal(5). Default: Info(0)

func DPanic

func DPanic() Level

func Debug

func Debug() Level

func Error

func Error() Level

func Fatal

func Fatal() Level

func Info

func Info() Level

func New

func New(level string) Level

New creates a new logging Level from a string input.

Allowed inputs: [Debug, Info, Warn, Error, DPanic, Panic, Fatal].
All other inputs will result in log Level Debug.

func NewFromInt

func NewFromInt(i int) Level

// NewFromInt creates a new logging Level. // // Available levels: [Debug(-1), Info(0), Warn(1), Error(2), DPanic(3), Panic(4), Fatal(5)]. // Inputs larger than 5 will result in Level Fatal(5). // Inputs smaller than -1 will result in Level Debug(-1).

func Panic

func Panic() Level

func Warn

func Warn() Level

func (Level) AllLevels

func (l Level) AllLevels() string

AllLevels returns a printed map of all possible logging inputs (keys and values are valid inputs)

func (Level) AsInt

func (l Level) AsInt() int

func (Level) Compare

func (l Level) Compare(i Level) int

func (Level) Is

func (l Level) Is(input Level) bool

func (Level) Print

func (l Level) Print() string

String returns the Logging Level in string form with integer form in parentheses

func (*Level) Set

func (l *Level) Set(v string) error

Set validates a Level input and overwrites the objects Level

func (Level) String

func (l Level) String() string

HumanReadable returns the Logging Level in plain string form

func (Level) Type

func (l Level) Type() string

Type returns the type of the Level

Jump to

Keyboard shortcuts

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