Simple, colorful, fun Go library for logging.
Go to file
Mirko Di 7405125a19 revert db4d277277
revert Added new license (MIT)
2023-10-07 12:50:50 +00:00
README.org Updated README; const -> var 2023-09-16 17:51:07 +02:00
colours.go Removed useless comment 2023-09-16 17:52:15 +02:00
go.mod Added source code 2023-09-16 17:35:19 +02:00
go.sum Added source code 2023-09-16 17:35:19 +02:00
logs.go Updated README; const -> var 2023-09-16 17:51:07 +02:00
random.go Added source code 2023-09-16 17:35:19 +02:00

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:

  1. log level (number from 0 to X): the lower this value is, the more important the log message is;
  2. 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;
  3. 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!