Skip to content
/ log-1 Public
forked from imroc/log

light weight and flexible logging framework of Go

License

Notifications You must be signed in to change notification settings

insionng/log-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

log

log is a logging framework of Go. see API.

Features

  • light weight
  • easy to use
  • level logging support
  • flexible

Quick Start

Installation
go get github.com/imroc/log
Simple Usage
import (
	"github.com/imroc/log"
)

func main() {
    // DEBUG < INFO < WARN < ERROR < FATAL
    log.SetLevel(log.WARN) // level DEBUG and INFO will not output
	log.Debug("this is a %s message", "debug")
	log.Info("this is a %s message", "info")
	log.Warn("this is a %s message", "warn")
	log.Error("this is a %s message", "error")
	log.Fatal("this is a %s message", "fatal")
}

output:

2016/10/04 14:38:38 WARN this is a warn message
2016/10/04 14:38:38 EROR this is a error message
2016/10/04 14:38:38 FATL this is a fatal message
More Control
file, _ := os.OpenFile("test.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
log.Set(log.INFO, file, log.Llongfile|log.LstdFlags)
log.Debug("this is a %s message", "debug")
log.Info("this is a %s message", "info")
log.Warn("this is a %s message", "warn")
log.Error("this is a %s message", "error")
log.Fatal("this is a %s message", "fatal")

output to test.log:

2016/10/04 15:04:00 INFO /home/cpwl/go/lib/src/github.com/imroc/sub/test.go:13: this is a info message
2016/10/04 15:04:00 WARN /home/cpwl/go/lib/src/github.com/imroc/sub/test.go:14: this is a warn message
2016/10/04 15:04:00 EROR /home/cpwl/go/lib/src/github.com/imroc/sub/test.go:15: this is a error message
2016/10/04 15:04:00 FATL /home/cpwl/go/lib/src/github.com/imroc/sub/test.go:16: this is a fatal message

LICENSE

log is is distributed under the terms of the MIT License.

About

light weight and flexible logging framework of Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%