logger

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Black = (iota + 30)
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

Color numbers for stdout

Variables

View Source
var (
	// Map for the various codes of colors
	Colors map[LogLevel]ctc.Color
)

Functions

func SetDefaultFormat

func SetDefaultFormat(format string)

func Stack

func Stack() string

Returns a string with the execution stack for this goroutine

Types

type Info

type Info struct {
	Id       uint64
	Time     string
	Module   string
	Level    LogLevel
	Line     int
	Filename string
	Message  string
}

Info class, Contains all the info on what has to logged, time is the current time, Module is the specific module For which we are logging, level is the state, importance and type of message logged, Message contains the string to be logged, format is the format of string to be passed to sprintf

func (*Info) Output

func (r *Info) Output(format string) string

Returns a proper string to be outputted for a particular info

type LogLevel

type LogLevel int

LogLevel type

const (
	CriticalLevel LogLevel = iota + 1
	ErrorLevel
	WarningLevel
	NoticeLevel
	InfoLevel
	DebugLevel
)

Log Level

type Logger

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

Logger class that is an interface to user to log messages, Module is the module for which we are testing worker is variable of Worker class that is used in bottom layers to log the message

func New

func New(args ...interface{}) *Logger

Returns a new instance of logger class, module is the specific module for which we are logging , color defines whether the output is to be colored or not, out is instance of type evo.Writer defaults to os.Stderr

func (*Logger) Critical

func (l *Logger) Critical(message string)

Critical logs a message at a Critical Level

func (*Logger) CriticalF

func (l *Logger) CriticalF(format string, a ...interface{})

CriticalF logs a message at Critical level using the same syntax and options as fmt.Printf

func (*Logger) Criticalf

func (l *Logger) Criticalf(format string, a ...interface{})

CriticalF logs a message at Critical level using the same syntax and options as fmt.Printf

func (*Logger) Debug

func (l *Logger) Debug(message string)

Debug logs a message at Debug level

func (*Logger) DebugF

func (l *Logger) DebugF(format string, a ...interface{})

DebugF logs a message at Debug level using the same syntax and options as fmt.Printf

func (*Logger) Debugf

func (l *Logger) Debugf(format string, a ...interface{})

DebugF logs a message at Debug level using the same syntax and options as fmt.Printf

func (*Logger) Error

func (l *Logger) Error(message string)

Error logs a message at Error level

func (*Logger) ErrorF

func (l *Logger) ErrorF(format string, a ...interface{})

ErrorF logs a message at Error level using the same syntax and options as fmt.Printf

func (*Logger) Errorf

func (l *Logger) Errorf(format string, a ...interface{})

ErrorF logs a message at Error level using the same syntax and options as fmt.Printf

func (*Logger) Fatal

func (l *Logger) Fatal(message string)

Fatal is just like func l.Critical logger except that it is followed by exit to program

func (*Logger) FatalF

func (l *Logger) FatalF(format string, a ...interface{})

FatalF is just like func l.CriticalF logger except that it is followed by exit to program

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, a ...interface{})

FatalF is just like func l.CriticalF logger except that it is followed by exit to program

func (*Logger) Info

func (l *Logger) Info(message string)

Info logs a message at Info level

func (*Logger) InfoF

func (l *Logger) InfoF(format string, a ...interface{})

InfoF logs a message at Info level using the same syntax and options as fmt.Printf

func (*Logger) Infof

func (l *Logger) Infof(format string, a ...interface{})

InfoF logs a message at Info level using the same syntax and options as fmt.Printf

func (*Logger) Log

func (l *Logger) Log(lvl LogLevel, message string)

The log commnand is the function available to user to log message, lvl specifies the degree of the messagethe user wants to log, message is the info user wants to log

func (*Logger) LogWrapped

func (l *Logger) LogWrapped(lvl LogLevel, message string) string

The log commnand is the function available to user to log message from wrapped function, lvl specifies the degree of the messagethe user wants to log, message is the info user wants to log

func (*Logger) Notice

func (l *Logger) Notice(message string)

Notice logs a message at Notice level

func (*Logger) NoticeF

func (l *Logger) NoticeF(format string, a ...interface{})

NoticeF logs a message at Notice level using the same syntax and options as fmt.Printf

func (*Logger) Noticef

func (l *Logger) Noticef(format string, a ...interface{})

NoticeF logs a message at Notice level using the same syntax and options as fmt.Printf

func (*Logger) Panic

func (l *Logger) Panic(message string)

Panic is just like func l.Critical except that it is followed by a call to panic

func (*Logger) PanicF

func (l *Logger) PanicF(format string, a ...interface{})

PanicF is just like func l.CriticalF except that it is followed by a call to panic

func (*Logger) Panicf

func (l *Logger) Panicf(format string, a ...interface{})

PanicF is just like func l.CriticalF except that it is followed by a call to panic

func (*Logger) SetFormat

func (l *Logger) SetFormat(format string)

func (*Logger) SetLogLevel

func (l *Logger) SetLogLevel(level LogLevel)

func (*Logger) StackAsCritical

func (l *Logger) StackAsCritical(message string)

Prints this goroutine's execution stack as critical with an optional message at the beginning

func (*Logger) StackAsError

func (l *Logger) StackAsError(message string)

Prints this goroutine's execution stack as an error with an optional message at the beginning

func (*Logger) Warning

func (l *Logger) Warning(message string)

Warning logs a message at Warning level

func (*Logger) WarningF

func (l *Logger) WarningF(format string, a ...interface{})

WarningF logs a message at Warning level using the same syntax and options as fmt.Printf

func (*Logger) Warningf

func (l *Logger) Warningf(format string, a ...interface{})

WarningF logs a message at Warning level using the same syntax and options as fmt.Printf

type Worker

type Worker struct {
	Minion *log.Logger
	Color  int
	// contains filtered or unexported fields
}

Worker class, Worker is a log object used to log messages and Color specifies if colored output is to be produced

func NewWorker

func NewWorker(prefix string, flag int, color int, out io.Writer) *Worker

Returns an instance of worker class, prefix is the string attached to every log, flag determine the log params, color parameters verifies whether we need colored outputs or not

func (*Worker) Log

func (w *Worker) Log(level LogLevel, calldepth int, info *Info) string

Function of Worker class to log a string based on level

func (*Worker) SetFormat

func (w *Worker) SetFormat(format string)

func (*Worker) SetLogLevel

func (w *Worker) SetLogLevel(level LogLevel)

Jump to

Keyboard shortcuts

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