logger

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

README

logger

Log it all

Documentation

Index

Constants

View Source
const (
	// LogInfo is used to log information messages
	LogInfo = iota
	// LogError is used to log error messages
	LogError
	// LogWarning is used to log warning messages
	LogWarning
	// LogDebug is used to log debug messages
	LogDebug
	// LogFatal is used log fatal messages and quit
	LogFatal
	// LogNoPrefix sets the type prefix to nothing.
	LogNoPrefix
)

Log type constants

Variables

This section is empty.

Functions

func DisableLoggingFile

func DisableLoggingFile()

Disables file logging and sets the file to the empty string("").

func GetFlags

func GetFlags() int

Gets the logger's flags.

func GetLoggingFile

func GetLoggingFile() (bool, string)

Returns if file logging is enabled and, if so, the path to the file.

func GetPrefix

func GetPrefix() string

Returns the custom prefix.

func GetStream

func GetStream() io.Writer

Gets the logger's stream.

func Log

func Log(logType int, msg string)

Log a message with a specified log type. Use the log type constants(LogInfo, LogError, LogWarning, LogDebug, and LogFatal) for the log type.

func Logf

func Logf(logType int, format string, a ...any)

Same as Log, except accepts a format string and format arguments.

func NewlineWithoutPrefix

func NewlineWithoutPrefix()

Logs a newline without any prefix(including the time, the custom prefix, and anything else from custom flags).

func SetFlags

func SetFlags(newFlags int)

Sets the logger's flags. Use the flags from the log package. log.Lmsgprefix is automatically set.

func SetLoggingFile

func SetLoggingFile(file string)

Sets the logging file to the specified value, enabling file logging if necessary. If the file passed is the empty string(""), then it will disable file logging.

Passing an empty string is equivalent to calling DisableLoggingFile.

func SetPrefix

func SetPrefix(newPrefix string)

Sets the custom prefix. This is appended before the type prefix([ERROR], [WARNING], etc).

func SetStream

func SetStream(stream io.Writer)

Sets the logger's stream.

Types

This section is empty.

Jump to

Keyboard shortcuts

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