lit is a Go package that provides
- A very simple and opinionated message logger
- Logging levels that allow you to set the verbosity of what is logged.
- Added detail, such as file, line, and function name to each logged message.
For help with this package or general Go discussion, please join the Discord Gophers chat server.
This package is pretty much where it's going to be, there's a chance of some minor changes in the future but otherwise I expect it to remain about like it is now.
I find somethings, like logging, a bit tedious. So I wanted a way to have a very accessible logger that I could use anywhere without needing much setup.
So, lit has minimal configuration options, it doesn't require to be instantiated as a variable you pass around, or a global one you setup somewhere. You can just call the package functions from anywhere and there are handy methods for each of the four log levels it supports.
Add the package to your project.
Look around your code, and find a place that needs something logged.
If it's an error, just add a line like
lit.Error("message here, %s", err)
Now that error message will be logged.
If it's something kind of spammy and not even an error at all - just detail you need when debugging your application.
lit.Debug("message here")
Now that will be logged anytime your lit.LogLevel
is set to lit.LogDebug
.
There's also lit.Warning()
and lit.Informational()
methods that can be used
similarly.
Can be set to lit.LogError
, lit.LogWarning
, lit.LogInformational
, and
lit.LogDebug
. The default is lit.LogError
.
Can be set to any string you want to prefix all logged messages. The default is
LIT
.
This can be set to any io.Writer and that's where your logged messages will go.
The default is os.Stderr
.