A lightweight and easy to use Go logging library that includes logging functionalities with different levels and custom formatting. It can also be used as a library to simply format the various messages you print in the terminal.
If you want to use this library for one of your projects, you can install it like any other Go library
go get github.com/kkrypt0nn/tangra
The prefix, what comes before the message, can be changed with the SetPrefix
method on a Logger
structure.
The default prefix is
${datetime} ${level:color}${level:name}${reset}:
There are formatting placeholders that will be replaced in both the message and the prefix that can be
seen here. All the placeholders in effect can be seen in
the placeholders example
.
For example, logging the following message
${fg:red}${effect:blink}${effect:bold}${sys:username} says hello!
Will print a red blinking message in bold that says <username> says hello!
, where <username>
is the username on your
system.
You can choose whether you want to style your messages or not with the SetStyling
method on a Logger
structure.
Styling includes foreground colors, background colors and special effects such as bold, and others - see
the terminal package.
Note: The styling will not apply to the message if it is not supported by the terminal.
Logs can also be written inside a log file with styling removed. See the example here.
This library was made with 💜 by Krypton and is under the MIT license.