Documentation ¶
Index ¶
- func Close()
- func Debug(msg string, args ...any)
- func Error(msg string, args ...any)
- func ErrorIfErr(err error, context string, args ...any) bool
- func Fatal(msg string, args ...any)
- func FatalIfErr(err error, context string, args ...any)
- func GetColor(l LogLevel) *color.Color
- func Init(callbacks ...LogCB)
- func PrintDebug(msg string, args ...any)
- func PrintSuccess(msg string, args ...any)
- func PrintWarn(msg string, args ...any)
- func Success(msg string, args ...any)
- func Warn(msg string, args ...any)
- type Closer
- type DoLog
- type FileInitorMode
- type LogCB
- type LogLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close()
Close all the outputs. Note: The logger does not check if the output is close or not, so it is safe to call this only at the end of the application.
func ErrorIfErr ¶
"While {CONTEXT}: {ERROR}" Returns true if err != nil, intended for inline usage: if ErrorIfErr(err, "fetching api info, status: %d", resp.StatusCode) { return }
func FatalIfErr ¶
"While {CONTEXT}: {ERROR}" This causes panic!
func PrintDebug ¶
Doesn't log anything, but prints in the pretty debug color Doesn't include a prefix.
func PrintSuccess ¶
Doesn't log anything, but prints in the pretty success color Doesn't include a prefix.
Types ¶
type FileInitorMode ¶ added in v1.1.0
type FileInitorMode int
const ( // This mode will overwrite the previous file that was written // Under this mode, the name will always be consistent FILE_OVERWRITE FileInitorMode = iota // This mode will append to the file names. The files will be named as 'fileName.0', 'fileName.1' etc. The most recent file will be the one with the highest extension. FILE_ASCENDING // This mode will 'shift' the files up by 1. The files will be named as 'fileName.0', 'fileName.1' etc. The most recent file will be the .0 one. FILE_DESCENDING )
type LogCB ¶
Function that is used in Init() - adds another callback to the caller. closer can be nil here, in which case it will not be called
func NewLoggerDiscordWebhook ¶
Send warnings/errors through a discord webhook
func NewLoggerFile ¶
Write logs to file This is an alias for NewLoggerFileComplex(fileName, FILE_ASCENDING, 10)
func NewLoggerFileComplex ¶ added in v1.1.0
func NewLoggerFileComplex(fileName string, mode FileInitorMode, maxNumber int) LogCB
maxNumber must be either >= 0. maxNumber indicates the max amount of files that can be stored. 0 indicates that an infinite amount of files can be stored. if mode == FILE_OVERWRITE, maxNumber is ignored. Please note the negative numbers do not count towards the maxNumber count! These are only made if a user renames a file to a negative number.