log

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// LevelDebug logs all messages.
	LevelDebug uint16 = iota
	// LevelInfo logs only informational messages and any others with greater severity.
	LevelInfo
	// LevelSuccess logs only success messages and any others with greater severity.
	LevelSuccess
	// LevelWarn logs only warning messages and any others with greater severity.
	LevelWarn
	// LevelError logs only error messages and any others with greater severity.
	LevelError
	// LevelFatal logs only fatal messages.
	LevelFatal
	// ConsoleLogger creates a new console logger when used in NewLogger().
	ConsoleLogger
	// FileLogger creates a new file logger when used in NewLogger().
	FileLogger
	// TransientLogger like consoleLogger
	TransientLogger
)

Variables

This section is empty.

Functions

func DisableColor

func DisableColor()

DisableColor disables color output to the terminal for console loggers. Log levels can still be differentiated by their prefixes.

func Initialize

func Initialize(myApp *grumble.App)

func NumericalLevel

func NumericalLevel(logger Logger, logLevel uint16, format string, args ...interface{})

func Print

func Print(args ...interface{})

Types

type Logger

type Logger interface {
	// Fatal is used when an application encounters a critical error, requiring
	// a shutdown.
	Fatal(format string, v ...interface{})
	// Error is used when a non-fatal error is raised.
	Error(format string, v ...interface{})
	// Warn is typically used to warn about errors that an application doesn't necessarily
	// have to shut down for.
	Warn(format string, v ...interface{})
	// Success is used when an operation completes successfully.
	Success(format string, v ...interface{})
	// Info is used for useful application notifications, such as an operation
	// completed successfully, or network operations such as received / sent requests and
	// responses.
	Info(format string, v ...interface{})
	// Debug is used for debug messages.
	Debug(format string, v ...interface{})
	// SetLogLevel determines which messages are logged based on their severity. For
	// example, a developer (or user) may choose to not log benign messages (debug, info)
	// to reduce noise.
	SetLogLevel(logLevel uint16) error
	// Close closes the logger and performs any necessary cleanup routines.
	Close() error
}

Logger interface declares methods used by both console loggers and file loggers. Console loggers display their output to the user, while file loggers write the output to a file. This functionality is useful for high volume and/or less urgent log messages, such as failed requests or other information.

func NewLogger

func NewLogger(loggerType uint16, name string) (Logger, error)

NewLogger creates either a file or console logger. Provided with a name, and type log.FileLogger, NewLogger will create a unique logfile - for readability, as well as thread safety. Preventing deadlocks is up to the log user, as they are responsible for creating unique names.

Jump to

Keyboard shortcuts

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