Skip to content

zj8487/go-dlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dlog

API Documentation MIT License

dlog wraps common functionality for common golang logging packages.

The dlog.Logger interface wraps the common logging functionality. Every method on dlog.Logger is also a global method on the dlog package. Given an implementation of dlog.Logger, you can register it as the global logger by calling:

func register(logger dlog.Logger) {
  dlog.SetLogger(logger)
}

To make things simple, packages for glog, logrus, and protolog are given with the ability to blank import:

import (
  _ "go.pedge.io/dlog/glog" // set glog as the global logger
  _ "go.pedge.io/dlog/logrus" // set logrus as the global logger with default settings
  _ "go.pedge.io/dlog/protolog" // set protolog as the global logger with default settings
)

Or, do something more custom:

func init() { // or anywhere
  logger := logrus.New()
  logger.Out = os.Stdout
  logger.Formatter = &logrus.TextFormatter{
    ForceColors: true,
  }
  dlog.SetLogger(logger)
}

By default, golang's standard logger is used.

About

Delegating logger for existing logging implementations https://godoc.org/go.pedge.io/dlog

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published