log

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DisableLevel disables all leveled logs (some output, such as usage, will be
	// still printed).
	DisableLevel = iota
	// FatalLevel logs indicates serious errors, which make program unable to
	// running.
	FatalLevel
	// ErrorLevel logs indicates errors which prevent program to perform some
	// function.
	ErrorLevel
	// WarnLevel logs indicates some less serious errors, which doesn't affect
	// program execution.
	WarnLevel
	// InfoLevel logs confirmates that things are working as expected.
	InfoLevel
	// VerboseLevel logs contain detailed information that should be
	// understandable to experienced users to provide insight in the software’s
	// behavior.
	VerboseLevel
	// DebugLevel logs contain detailed information, typically of interest only
	// when diagnosing problems.
	DebugLevel
	// SpamLevel logs are too verbose for regular debbuging.
	SpamLevel
)
View Source
const (
	EscapeMarkerMode     = "klio_mode"
	EscapeMarkerLogLevel = "klio_log_level"
	EscapeMarkerTags     = "klio_tags"
	EscapeMarkerReset    = "klio_reset"
)
View Source
const DefaultErrorLevel = ErrorLevel

DefaultErrorLevel represents default level for error logs.

View Source
const DefaultLevel = InfoLevel

DefaultLevel represents default level for non-error logs.

View Source
const MaxLevel = SpamLevel

MaxLevel represents maximum level for logs.

Variables

View Source
var (
	DefaultLogger = NewLogger(os.Stdout)
	ErrorLogger   = NewLogger(os.Stderr)
)
View Source
var LevelNames = []string{"disable", "fatal", "error", "warn", "info", "verbose", "debug", "spam"}

LevelNames contains all supported names of logging levels.

Functions

func Debug

func Debug(v ...interface{})

Debug will print only when logger's Level is debug or spam.

func Debugf

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

Debugf will print only when logger's Level is debug or spam.

func Error

func Error(v ...interface{})

Error will print only when logger's Level is error, warn, info, verbose, debug or spam.

func Errorf

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

Errorf will print only when logger's Level is error, warn, info, verbose, debug or spam.

func Fatal

func Fatal(v ...interface{})

Fatal `os.Exit(1)` exit no matter the level of the logger. If the logger's level is fatal, error, warn, info, verbose debug or spam then it will print the log message too.

func Fatalf

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

Fatalf will `os.Exit(1)` no matter the level of the logger. If the logger's level is fatal, error, warn, info, verbose debug or spam then it will print the log message too.

func GetDefaultErrorLevel added in v1.1.0

func GetDefaultErrorLevel() string

GetDefaultErrorLevel returns default error logging level name.

func GetDefaultLevel

func GetDefaultLevel() string

GetDefaultLevel returns default logging level name.

func GetLevel

func GetLevel() string

GetLevel returns current logging level name.

func GetSupportedLevels added in v1.1.0

func GetSupportedLevels() []string

GetSupportedLevels returns supported logging levels.

func IncreaseLevel

func IncreaseLevel(levels int)

IncreaseLevel changes current level by specified number.

func Info

func Info(v ...interface{})

Info will print only when logger's Level is info, verbose, debug or spam.

func Infof

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

Infof will print only when logger's Level is info, verbose, debug or spam.

func Log

func Log(level Level, v ...interface{})

Log prints message with specified level.

func Logf

func Logf(level Level, format string, args ...interface{})

Logf prints message with specified level.

func Printf added in v1.1.0

func Printf(format string, args ...interface{})

Printf prints a log message without levels and colors.

func Println

func Println(v ...interface{})

Println prints a log message without levels and colors.

func SetLevel

func SetLevel(levelName string)

SetLevel sets minimum level for logs, logs with level above specified value will not be printed.

func SetLevelFromEnv

func SetLevelFromEnv()

SetLevelFromEnv sets minimum level for logs based on environment variables

func Spam

func Spam(v ...interface{})

Spam will print when logger's Level is spam.

func Spamf

func Spamf(format string, args ...interface{})

Spamf will print when logger's Level is spam.

func Verbose

func Verbose(v ...interface{})

Verbose will print only when logger's Level is verbose, debug or spam.

func Verbosef

func Verbosef(format string, args ...interface{})

Verbosef will print only when logger's Level is verbose, debug or spam.

func Warn

func Warn(v ...interface{})

Warn will print only when logger's Level is warn, info, verbose, debug or spam.

func Warnf

func Warnf(format string, args ...interface{})

Warnf will print only when logger's Level is warn, info, verbose, debug or spam.

Types

type Level

type Level uint32

Level is a number which defines the log level.

type LevelConfig

type LevelConfig struct {
	Name        string
	DisplayText string
	Color       int
}

type Logger

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

func NewLogger

func NewLogger(output io.Writer) *Logger

func (*Logger) Debug added in v1.1.0

func (l *Logger) Debug(v ...interface{})

Debug will print only when logger's Level is debug or spam.

func (*Logger) Debugf added in v1.1.0

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

Debugf will print only when logger's Level is debug or spam.

func (*Logger) Error added in v1.1.0

func (l *Logger) Error(v ...interface{})

Error will print only when logger's Level is error, warn, info, verbose, debug or spam.

func (*Logger) Errorf added in v1.1.0

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

Errorf will print only when logger's Level is error, warn, info, verbose, debug or spam.

func (*Logger) Fatal added in v1.1.0

func (l *Logger) Fatal(v ...interface{})

Fatal `os.Exit(1)` exit no matter the level of the logger. If the logger's level is fatal, error, warn, info, verbose debug or spam then it will print the log message too.

func (*Logger) Fatalf added in v1.1.0

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

Fatalf will `os.Exit(1)` no matter the level of the logger. If the logger's level is fatal, error, warn, info, verbose debug or spam then it will print the log message too.

func (*Logger) Info added in v1.1.0

func (l *Logger) Info(v ...interface{})

Info will print only when logger's Level is info, verbose, debug or spam.

func (*Logger) Infof added in v1.1.0

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

Infof will print only when logger's Level is info, verbose, debug or spam.

func (*Logger) Printf added in v1.1.0

func (l *Logger) Printf(format string, args ...interface{})

Printf formats according to the specified format without levels and colors.

func (*Logger) Println

func (l *Logger) Println(v ...interface{})

Println prints a log message without levels and colors.

func (*Logger) Spam added in v1.1.0

func (l *Logger) Spam(v ...interface{})

Spam will print when logger's Level is spam.

func (*Logger) Spamf added in v1.1.0

func (l *Logger) Spamf(format string, args ...interface{})

Spamf will print when logger's Level is spam.

func (*Logger) Verbose added in v1.1.0

func (l *Logger) Verbose(v ...interface{})

Verbose will print only when logger's Level is verbose, debug or spam.

func (*Logger) Verbosef added in v1.1.0

func (l *Logger) Verbosef(format string, args ...interface{})

Verbosef will print only when logger's Level is verbose, debug or spam.

func (*Logger) Warn added in v1.1.0

func (l *Logger) Warn(v ...interface{})

Warn will print only when logger's Level is warn, info, verbose, debug or spam.

func (*Logger) Warnf added in v1.1.0

func (l *Logger) Warnf(format string, args ...interface{})

Warnf will print only when logger's Level is warn, info, verbose, debug or spam.

func (*Logger) WithDefaultLevel added in v1.1.1

func (l *Logger) WithDefaultLevel(level Level) *Logger

WithDefaultLevel allows to set default level for logger

func (*Logger) WithOutput added in v1.1.1

func (l *Logger) WithOutput(output io.Writer) *Logger

WithOutput allows to set custom output for logger

type Mode

type Mode string

type Processor

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

func NewProcessor added in v1.1.0

func NewProcessor(DefaultLevel Level, Logger *Logger, Input io.Reader) *Processor

func (*Processor) Process

func (lp *Processor) Process()

Jump to

Keyboard shortcuts

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