Skip to content

Use logrus and log frontend, and bridge to various storage backend.

License

Notifications You must be signed in to change notification settings

kmiku7/logrus-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logrus-bridge

Use logrus and log frontend, and bridge to various storage backend.

Code Example:

import (
  "io/ioutil"

  "github.com/kmiku7/logrus-bridge/formatter"
  "github.com/kmiku7/logrus-bridge/hooks"
  "github.com/kmiku7/logrus-bridge/logger"
  "github.com/sirupsen/logrus"
)

var GlobalLoggerClient logger.Logger


func InitGlobalLogger() {
  var backend hooks.Backend // = SomePackage.NewBackend(...)

  logClient := logrus.New()
  logClient.Out = ioutil.Discard
  logClient.Formatter = formatter.EmptyFormatter(0)
  logClient.SetLevel(logrus.DebugLevel)
  
  hook := hooks.NewBackendHook(
    backend,
    &logrus.TextFormatter{},
    logrus.AllLevels)
  logClient.AddHook(hook)
  
  GlobalLoggerClient = logClient
}

func main() {
  InitGlobalLogger()
  
  GlobalLoggerClient.Info("Hello World!")
}

About

Use logrus and log frontend, and bridge to various storage backend.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages