Go to file
2023-04-30 20:58:44 +02:00
go.mod first version 2023-04-30 20:57:06 +02:00
go.sum first version 2023-04-30 20:57:06 +02:00
LICENSE first version 2023-04-30 20:57:06 +02:00
log_test.go first version 2023-04-30 20:57:06 +02:00
log.go first version 2023-04-30 20:57:06 +02:00
README.md fixed README 2023-04-30 20:58:44 +02:00

log

Package log provides a uniform method of logging.

how to use this?

just import this module into your Go project by adding the following line to your imports:

"git.stinnesbeck.com/go/log"

You can use this package in your code as follows:

log.Print(LOGLEVEL, "This is your message of type LOGLEVEL")
log.PrintInfo("This is your info message")
log.PrintWarning("This is your warning message")
log.PrintError("This is your error message")
log.PrintDebug("This is your debug message")

Log levels

The following log levels are supported:

LogLevel Name
0 ERROR
1 WARNING
2 INFO
3 DEBUG

The package will honor a globally set environment variable LOGLEVEL. The package will only print levels that are less or equal than the one provided (e.g. WARNING will only print ERROR and WARNING). If no environment variable is set or it can't be parsed into the names above, ERROR will be selected as the default.

Example usage

You can see an example output by cloning this repo and executing:

go test