Skip to content

Discontinued in favor of log/slog. liblog was an interface/contract for logging backends. It was used by public libraries and packages that wanted to give their user's control over structured and leveled logging output.

License

Notifications You must be signed in to change notification settings

harwoeck/liblog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

liblog

Caution

DISCONTINUED in favor of log/slog

liblog was an interface/contract for logging backends. It was used by public libraries and packages that wanted to give their user's control over structured and leveled logging output.

Go Reference

Advantages

  • 🟢 Users can provide their own logging stack and get detailed package-level logging
  • 🟢 liblog provides implementations for well-known logging backends (see /impl)

Getting started

  • go get github.com/harwoeck/liblog - provides the liblog interface, and an implementation that only relies on Go's standard library
  • Use liblog.NewStd(...StdOption) by default inside your package, but give users the option to specify their own logging implementation (liblog.Logger)

Usage

  • Extensively use all provided options, like Named(), With() and appropriate logging levels, to provide the best log results/experience.
  • Use field() (or liblog.NewField()) to generate structured elements for your logs (see Tips #1)

Tips

  1. Create a file logfield.go and add this fieldImpl. You can now use field() instead of the longer liblog.NewField() inside your package to create structured logging elements
    type fieldImpl struct {
        key   string
        value interface{}
    }
    
    func (f *fieldImpl) Key() string        { return f.key }
    func (f *fieldImpl) Value() interface{} { return f.value }
    
    func field(key string, value interface{}) contract.Field {
        return &fieldImpl{
            key:   key,
            value: value,
        }
    }

About

Discontinued in favor of log/slog. liblog was an interface/contract for logging backends. It was used by public libraries and packages that wanted to give their user's control over structured and leveled logging output.

Topics

Resources

License

Stars

Watchers

Forks

Languages