Skip to content

Instantly share code, notes, and snippets.

@genghisjahn
Created June 1, 2015 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genghisjahn/a7d2cd19f5d34dc8fe7c to your computer and use it in GitHub Desktop.
Save genghisjahn/a7d2cd19f5d34dc8fe7c to your computer and use it in GitHub Desktop.
Golang logging example
package main
import (
"os"
"github.com/go-logging"
)
//https://github.com/op/go-logging/
var log = logging.MustGetLogger("main")
func main() {
logging.SetFormatter(logging.MustStringFormatter("%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}"))
logBackend := logging.NewLogBackend(os.Stdout, "", 0)
logging.SetBackend(logBackend)
logger := logging.MustGetLogger("main")
logging.SetLevel(logging.DEBUG, "main")
logger.Debug("hello golang")
logger.Critical("BOOM!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment