logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

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

Color numbers for stdout

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Id      uint64
	Time    string
	Module  string
	Level   string
	Message string
	// contains filtered or unexported fields
}

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() string

Returns a proper string to be outputted for a particular info

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 NewLogger

func NewLogger(args ...interface{}) (*Logger, error)

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 io.Writer defaults to os.Stderr

func (*Logger) Critical

func (l *Logger) Critical(message string)

Critical logs a message at a Critical Level

func (*Logger) Debug

func (l *Logger) Debug(message string)

Debug logs a message at Debug level

func (*Logger) Error

func (l *Logger) Error(message string)

Error logs a message at Error level

func (*Logger) Fatal

func (l *Logger) Fatal(message string)

Fatal is just like func l,Cr.tical 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) Log

func (l *Logger) Log(lvl string, 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) Notice

func (l *Logger) Notice(message string)

Notice logs a message at Notice level

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) Warning

func (l *Logger) Warning(message string)

Warning logs a message at Warning level

type Worker

type Worker struct {
	Minion *log.Logger
	Color  int
}

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 string, calldepth int, info *Info) error

Function of Worker class to log a string based on level

Jump to

Keyboard shortcuts

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