Skip to content
/ log Public

logrus wrapper with source code information and function name

License

Notifications You must be signed in to change notification settings

coreswitch/log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

log

log is a wrapper for logrus Go logging package. To help debugging, log added source code information and function name to logrus output.

Example

The simple example for enabling debug level for DEBUG and set output to stdout.

package main

import (
  log "github.com/coreswitch/log"
)

func main() {
  log.SetLevel("debug")
  log.SetOutput("stdout")

  log.With("animal", "walrus").Info("A walrus appears")
}

The example set formatter to JSON.

package main

import (
  log "github.com/coreswitch/log"
)

func main() {
  log.SetLevel("debug")
  log.SetJSONFormatter()

  log.With("animal", "zebra").Debug("A zebra appears")
}

Source field and function field is configurable.

package main

import (
  log "github.com/coreswitch/log"
)

func main() {
  log.SourceField = false
  log.FuncField = false

  log.With("animal", "bird").Warn("A crow appears")
}

About

logrus wrapper with source code information and function name

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages