logger

package module
v0.0.0-...-b067be5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// When logging to file this file will be used.
	FilePath string

	// Makes FilePath threaded as an dir and names logfiles to what this function returns.
	DynamicFileName func() string

	// Mapping of Vebosities to set allowed verbosities and their priority.
	Verbosities Verbosities

	// Minimal verbose priotity to log message to CLI.
	VerboseToCLI int

	// Minimal verbose priotity to log message to file.
	VerboseToFile int

	// When true logged messages will be prepended with the date time.
	AppendDateTime bool

	// When true logged messages will be prepended with the verbosity.
	AppendVerbosity bool

	// Prepent every log message to CLI.
	PrepentCLI string

	// Hook to call after an message has been logged to CLI.
	MessageCLIHook func(msg string)

	// Minimal char space a message part will take up.
	CharCountPerMsg int

	// Minimal char space the verbosity part will take up (AppendVerbosity must be true to take effect).
	CharCountVerbosity int

	// When true RecordSepperator and EORSepperator are used when loggin to file, otherwise log the raw message.
	UseSeperators bool

	// Seperator string between message parts when logging to file (Logged message can not contain this string).
	RecordSepperator string

	// End of record string after a message when logging to file (Logged message can not contain this string).
	EORSepperator string
}

func New

func New(filePath string) *Logger

Create new logger instance and return a pointer to it.

func (Logger) Log

func (logger Logger) Log(verbosity string, msgs ...any)

Log an message. Verbosity detirmance if the message will be logged to the CLI and/ or the file. The Logger variables can be altert to modify the behavoir of Log (See logger.New).

type Verbosities

type Verbosities map[string]int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳