revert Added new license (MIT) |
||
---|---|---|
README.org | ||
colours.go | ||
go.mod | ||
go.sum | ||
logs.go | ||
random.go |
README.org
Logs
Logs
Simple, colorful, fun Go library for logging.
Usage
Run the following in a terminal:
go get git.mirkodi.eu/mirk0dex/logs
Then, you may use the library, in your program, as follows:
package main
import (
"git.mirkodi.eu/mirk0dex/logs"
)
func main() {
logs.LOGENABLE = true
logs.LOGLEVEL = 3 // 0 (min) = only non-fatal errors
logs.Log(1, "Log title", "Hello world!")
}
Arguments
Args logs.Log() expects are, in order:
- log level (number from 0 to X): the lower this value is, the more important the log message is;
- log title: colorful title for a type of logs, should be the same for all messages of the same type/sent from the same function;
- log message.
Settings
You can configure logs to better fit your needs, by settings the changing variables:
- logs.LOGENABLE (which can be either true or false) [default is 'true'];
- logs.LOGLEVEL (number from 0 to X). The greater this number is, the more verbose your program will be. [default is '3'];
- logs.LOGPREFIX, printed before log title [default is "— Log: "];
- logs.LOGCOLOURED (can be either true or false), which enables/disables coloured logs [default is 'true'];
- logs.LOGSUFFIX, printed after log message [default is ".\n"];
- logs.LOGTITLEANDMSGSEPARATOR. This separates your log title and log message [default is " - "].
Features
- Each log title is hashed and a random colour is generated. Each log title has its unique text colour.
- New colours every time.
- Simple log level system.
- Easy to enable/disable.
License
This library is licensed under the WTFPL. It comes with no warranty!