Skip to content
/ lit Public

Lit (Log it) is a simple and opinionated message logger for Go (golang).

License

Notifications You must be signed in to change notification settings

bwmarrin/lit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lit logs, so hot.

GoDoc Go report Build Status Discord Gophers

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.

Status @ 2019-03-02

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.

Design Goals

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.

Usage

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.

Options

lit.LogLevel

Can be set to lit.LogError, lit.LogWarning, lit.LogInformational, and lit.LogDebug. The default is lit.LogError.

lit.Prefix

Can be set to any string you want to prefix all logged messages. The default is LIT.

lit.Writer

This can be set to any io.Writer and that's where your logged messages will go. The default is os.Stderr.

About

Lit (Log it) is a simple and opinionated message logger for Go (golang).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages