log

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: BSD-3-Clause Imports: 9 Imported by: 8

Documentation

Overview

Package log contains an interface to logging system

Index

Constants

This section is empty.

Variables

View Source
var (
	// Effects is a map of the tokens that can be used in Format to
	// change the properties of the text.
	Effects = map[string]string{
		"{bold}":        tui.BOLD,
		"{dim}":         tui.DIM,
		"{red}":         tui.RED,
		"{green}":       tui.GREEN,
		"{blue}":        tui.BLUE,
		"{yellow}":      tui.YELLOW,
		"{f:black}":     tui.FOREBLACK,
		"{f:white}":     tui.FOREWHITE,
		"{b:darkgray}":  tui.BACKDARKGRAY,
		"{b:red}":       tui.BACKRED,
		"{b:green}":     tui.BACKGREEN,
		"{b:yellow}":    tui.BACKYELLOW,
		"{b:lightblue}": tui.BACKLIGHTBLUE,
		"{reset}":       tui.RESET,
	}

	FormatConfigBasic = FormatConfig{
		DateFormat:     dateFormat,
		TimeFormat:     timeFormat,
		DateTimeFormat: dateTimeFormat,
		Format:         format,
	}
)
View Source
var (
	// LevelNames is a map of the names ( {level:name} ) of each verbosity level.
	LevelNames = map[Verbosity]string{
		VERBOSE:   "ver",
		DEBUG:     "dbg",
		INFO:      "inf",
		IMPORTANT: "imp",
		WARNING:   "war",
		ERROR:     "err",
		FATAL:     "!!!",
	}
	// LevelColors is a map of the colors ( {level:color} ) of each verbosity level.
	LevelColors = map[Verbosity]string{
		VERBOSE:   tui.DIM + tui.FOREBLACK + tui.BACKYELLOW,
		DEBUG:     tui.DIM + tui.FOREBLACK + tui.BACKDARKGRAY,
		INFO:      tui.FOREWHITE + tui.BACKGREEN,
		IMPORTANT: tui.FOREWHITE + tui.BACKLIGHTBLUE,
		WARNING:   tui.FOREWHITE + tui.BACKYELLOW,
		ERROR:     tui.FOREWHITE + tui.BACKRED,
		FATAL:     tui.FOREWHITE + tui.BACKRED + tui.BOLD,
	}
)
View Source
var (
	NoEffects = false
)

Functions

func AddOutput added in v1.21.1

func AddOutput(path string, level Verbosity, config FormatConfig, NoEffects bool) (err error)

func Debug

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

Debug emits a debug message.

func Error

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

Error emits an error message.

func Fatal

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

Fatal emits a fatal error message and calls the OnFatal callback.

func Important

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

Important emits an important informative message.

func Info

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

Info emits an informative message.

func Init

func Init(opt core.Options, isLogToFile bool, logFilePath string)

func LevelColor added in v1.21.1

func LevelColor(v Verbosity) string

LevelColor returns the color of a verbosity level or "" if effects are disabled.

func LevelName added in v1.21.1

func LevelName(v Verbosity) string

LevelName returns the name of a verbosity level.

func Raw

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

Raw emits a message without format to the logs.

func Verbose added in v1.21.1

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

Verbose emits a verbose message.

func Warning

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

Warning emits a warning message.

Types

type FormatConfig added in v1.21.1

type FormatConfig struct {
	DateFormat     string
	TimeFormat     string
	DateTimeFormat string
	Format         string
}

type Verbosity added in v1.21.1

type Verbosity int

Verbosity represents the verbosity level of the logger.

const (
	// Verbose messages
	VERBOSE Verbosity = iota
	// Debug messages.
	DEBUG
	// Informative messages.
	INFO
	// Informative messages that are important.
	IMPORTANT
	// Warning messages.
	WARNING
	// Recoverable error conditions.
	ERROR
	// Fatal error conditions.
	FATAL
)

Jump to

Keyboard shortcuts

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