~poldi1405/glog

because the world just needed another logging library.
ed5d1eda — Moritz Poldrack 3 years ago
updated formatter dependencies
ad160a18 — Moritz Poldrack 3 years ago
added first work on logformats
3758f15d — Moritz Poldrack 3 years ago
added Contribution Guidelines

clone

read-only
https://git.sr.ht/~poldi1405/glog
read/write
git@git.sr.ht:~poldi1405/glog

You can also use your local clone with git send-email.

#gLog

Your silver bullet logging solution. Because that is definitely what the world needed: another logging library.

Coverage current Version: v1.0.0 License godocs.io no non-stdlib deps that must be credited*

#Features

gLog supports the following features:

  • log-levels
  • smart-colors
  • customization
  • caller-insertion
  • multiple outputs
  • log rotation
  • panic-handling
  • conditionals:
    • output per logging level
    • caller from a certain level
  • sane defaults
#coming soon™:
  • "plug-n-play" log formats

#Output

The output follows this structure:

%level:\t%time – %caller – …

%level is coloured by default when logging to stdout or stderr. It can be enabled and disabled at will.

%time is in the ISO-8601 format working with nanosecond precision (if supported)

%caller is the name (format: package.function) of the function that is logging the message. By default, this does not happen for INFO and WARNING.

#Why and not -

I decided to use U+2013 (EN DASH) over a normal U+002D (HYPHEN-MINUS) due to multiple reasons; some of which are:

  • 2D is not at all unlikely to appear in a log-message
  • they look very similar while they can still be distinguished
  • it is also in most fonts used in a terminal
    • if it is not in your's think about changing fonts
  • it allows for easy splitting and processing of logs with tools like cut or awk
  • you don't have to type it by hand anyway

#Levels

Level Description
TRACE Print everything. This is usually not wanted unless debugging.
DEBUG Print every function call.
INFO Print general status messages like HTTP-Requests (a good default)
WARNING Handled errors. (the better default¹)
ERROR Non-Critical Errors like access denied
FATAL Errors that do not allow the Program to continue

¹) "no news is good news" or so they say

#Notes

  • Obviously, setting a low loglevel will slow down your program, as the writing is not buffered and getting the caller is relatively expensive
    • using StdOut/StdErr for logging decreases this time because it does not need to write to disk

#Learn more

You can find more information in this project's wiki

#NO_COLOR

glog respects NO_COLOR

#Contribute

Contributions are welcome from anyone. Just send a patchset to ~poldi1405/patches@lists.sr.ht and wait for feedback. For general questions or other communications feel free to drop a message to ~poldi1405/discussion@lists.sr.ht

Updates will be announced here

The changelog can be found here

#License

* the claim 0 external dependencies refers to 0 dependencies that have to be credited. By crediting this package, the crediting for the only external dependency is also fulfilled

© Moritz Poldrack and contributors

gLog is a gun unter the MPL-2.0

To learn more you may:

  • read the license-text here
  • take a look at the official FAQs
  • take a look at a summary at TLDRLegal
Do not follow this link