Skip to content

dolab/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logger

Build Status

Efficent and simpe logger for golang with more features supported.

  • custom log levels

  • custom log tags

  • custom log colors (only worked for *NIX)

  • custom log output and output format

Install

go get -u github.com/dolab/logger

Usage

import "github.com/dolab/logger"

func main() {
    log, _ := logger.New("stdout")
    log.SetLevel(logger.Ldebug)

    // normal
    log.Debug("Hello, logger!")
    log.Infof("Hello, %s!", "logger")

    // create new logger with tags based on log
    taggedLog := log.New("X-REQUEST-ID")
    taggedLog.Debug("Receive HTTP request")
    taggedLog.Warnf("Send response with %d.", 200)
}

Output

  • stdout = os.Stdout
  • stderr = os.Stderr
  • null | nil = os.DevNull
  • path/to/file = os.OpenFile("path/to/file", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)

Level

  • Ldebug = DEBUG
  • Linfo = INFO
  • Lwarn = WARN
  • Lerror = ERROR
  • Lfatal = FATAL
  • Lpanic = PANIC
  • Ltrace = Stack

License

MIT

Author

Spring MC

About

Efficent and simple logger for golang with much more features.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages