log

package module
v2.3.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: BSD-3-Clause Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// CLITimeFmt command line interface
	CLITimeFmt string = "rfc822"
	// DefTimeFmt default time format
	DefTimeFmt string = "rfc3339"
	// DetailedTimeFmt has nanoseconds
	DetailedTimeFmt string = "rfc3339Nano"
	// CLIFormat  command line interface
	CLIFormat string = "cli"
	// PlainFormat just print message
	PlainFormat string = "plain"
	// PlainFormatWithEmoji just print message with emoji
	PlainFormatWithEmoji string = "plain-emoji"
	// StdFormat standard format
	StdFormat string = "std"
	// StdFormatWithEmoji same as above with an emoji
	StdFormatWithEmoji string = "std-emoji"
	// SimpleFormat short
	SimpleFormat string = "simple"
	// JSONFormat initial attempt at supporting json
	JSONFormat string = "json"
)

Variables

View Source
var (
	// Formats exported formats
	Formats = map[string]Format{
		CLITimeFmt: {
			Name: CLITimeFmt,
			// contains filtered or unexported fields
		},
		DefTimeFmt: {
			Name: DefTimeFmt,
			// contains filtered or unexported fields
		},
		DetailedTimeFmt: {
			Name: DetailedTimeFmt,
			// contains filtered or unexported fields
		},
		CLIFormat: {
			Name: CLIFormat,
			// contains filtered or unexported fields
		},
		PlainFormat: {
			Name: PlainFormat,
			// contains filtered or unexported fields
		},
		PlainFormatWithEmoji: {
			Name: PlainFormatWithEmoji,
			// contains filtered or unexported fields
		},
		StdFormat: {
			Name: StdFormat,
			// contains filtered or unexported fields
		},
		StdFormatWithEmoji: {
			Name: StdFormatWithEmoji,
			// contains filtered or unexported fields
		},
		SimpleFormat: {
			Name: SimpleFormat,
			// contains filtered or unexported fields
		},
		JSONFormat: {
			Name: JSONFormat,
			// contains filtered or unexported fields
		},
	}
)
View Source
var (
	// Levels map all levels to their stuff (a color). also i spent a lot of time deciding these defaults
	Levels = map[Lvl]Level{
		LCrit: initLvl(
			1,
			"FATAL",
			"Red",
			128557,
		),
		LErr: initLvl(
			2,
			"ERROR",
			"Magenta",
			128545,
		),
		LWarn: initLvl(
			3,
			"WARN",
			"Yellow",
			128548,
		),
		LNotice: initLvl(
			4,
			"NOTICE",
			"Green",
			128516,
		),
		LInfo: initLvl(
			5,
			"INFO",
			"Cyan",
			128523,
		),
		LDebug: initLvl(
			6,
			"DEBUG",
			"White",
			128533,
		),
	}
)

Functions

func Critical

func Critical(message string)

Critical logs a message at a Critical Level

func Criticalf

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

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

func Debug

func Debug(message string)

Debug logs a message at Debug level

func Debugf

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

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

func Error

func Error(message string)

Error logs a message at Error level

func Errorf

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

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

func Fatal

func Fatal(message string)

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

func Fatalf

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

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

func Info

func Info(message string)

Info logs a message at Info level

func Infof

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

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

func IsValidLevel

func IsValidLevel(i int) error

func Log

func Log(lvl Lvl, message string)

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

func Notice

func Notice(message string)

Notice logs a message at Notice level

func Noticef

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

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

func Panic

func Panic(message string)

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

func Panicf

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

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

func SetDefaultFormat

func SetDefaultFormat()

SetDefaultFormat used to

func SetLevel

func SetLevel(id int, name, color string, emoji int)

SetLevel to create or reconfigure a level

func StackAsCritical

func StackAsCritical(message string)

StackAsCritical Prints a goroutine's execution stack as critical with an optional message at the begining

func StackAsError

func StackAsError(message string)

StackAsError Prints a goroutine's execution stack as an error with an optional message at the begining

func Warning

func Warning(message string)

Warning logs a message at Warning level

func Warningf

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

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

Types

type Format

type Format struct {
	Name string
	// contains filtered or unexported fields
}

Format is a format :D

func (Format) String

func (f Format) String() string

type Level

type Level struct {
	ID  int    // export this for comamndlines etc
	Str string // and this
	// contains filtered or unexported fields
}

Level struct

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(format, timeformat string, args ...interface{}) (Logger, error)

New 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) 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) 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) 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) 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) Log

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

Log The log commnand is the function available to user to log message, lvl specifies the degree of the message the 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) Output

func (l *Logger) Output(calldepth int, s string) error

Output ...

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

func (l *Logger) SetFormat(format string)

SetFormat ...

func (*Logger) SetLogLevel

func (l *Logger) SetLogLevel(level Lvl)

SetLogLevel to change verbosity

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

SetOutput ...

func (*Logger) StackAsCritical

func (l *Logger) StackAsCritical(message string)

StackAsCritical Prints a goroutine's execution stack as critical with an optional message at the begining

func (*Logger) StackAsError

func (l *Logger) StackAsError(message string)

StackAsError Prints a goroutine's execution stack as an error with an optional message at the begining

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

type Lvl

type Lvl int

Lvl is a verbosity level

const (
	LCrit Lvl = iota
	LErr
	LWarn
	LNotice
	LInfo
	LDebug
	LDefault = LNotice
)

Log Level

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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