logger

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Overview

Utility functions for logging messages and errors

Index

Constants

View Source
const (
	Error   logType = 0
	Warning logType = 1
	Info    logType = 2
	List    logType = 3
	Done    logType = 4
	Debug   logType = 5

	SUCCESS     int = 0
	ERR_GENERIC int = 1
	ERR_UNKNOWN int = 2

	ERR_USAGE     int = 10
	ERR_INPUT     int = 11
	ERR_FILE_READ int = 12
	ERR_CLOSABLE  int = 13

	ERR_CONNECTION int = 30
	ERR_WRITE      int = 31
	ERR_PARSE      int = 32
)

Variables

View Source
var MapTypesToPrefix = map[logType]string{
	Error:   MapTypesToColor[Error].Sprint("[ERR]"),
	Warning: MapTypesToColor[Warning].Sprint("[WRN]"),
	Info:    MapTypesToColor[Info].Sprint("[INF]"),
	List:    MapTypesToColor[List].Sprint("[LST]"),
	Done:    MapTypesToColor[Done].Sprint("[DON]"),
	Debug:   MapTypesToColor[Debug].Sprint("[DBG]"),
}

Functions

func EnableLogging

func EnableLogging(flag bool)

EnableLogging enables or disables logging globally.

func Log

func Log(messageType logType, messages ...string)

Log a timestamped message with a given logType.

func LogError

func LogError(err error)

LogError logs the provided error as an error message.

func LogPlain

func LogPlain(messageType logType, messages ...string)

LogPlain logs a message without a timestamp.

func LogReturn

func LogReturn(messageType logType, messages ...string) string

LogReturn returns the formatted log string instead of printing it.

func Logf

func Logf(messageType logType, format string, data ...interface{})

Logf functions like fmt.Printf for a given logType.

func SetLogFile

func SetLogFile(filename string) error

SetLogFile sets the file to which logs will be written.

func SetLogLevel added in v1.2.7

func SetLogLevel(level logType)

SetLogLevel sets the current minimum log level to show

func SetLogLevelByName added in v1.2.7

func SetLogLevelByName(level string)

SetLogLevelByName sets the log level using a string (e.g., "info", "error").

func TruncateLogFileIfTooLarge added in v1.2.7

func TruncateLogFileIfTooLarge(maxBytes int64) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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