commit | 25022f9bbde4ef62a365891e359e85d00a80b271 | [log] [tgz] |
---|---|---|
author | spf13 <steve.francia@gmail.com> | Fri Mar 28 01:35:08 2014 -0400 |
committer | spf13 <steve.francia@gmail.com> | Fri Mar 28 01:39:40 2014 -0400 |
tree | 6c3fac5055141f6f66f837d33248641a650cff2e | |
parent | f6d2d9deed16ec79045fb1bf4f1d2a26be0c0055 [diff] |
First pretty stable release
A simple printing and logging library for go
Graphic by JonnyEtc
JWW is primarily a convenience wrapper around the excellent standard log library.
I really wanted a very straightforward library that could seamlessly do the following things.
Put calls throughout your source based on type of feedback.
Available Loggers are:
These each are loggers based on the log standard library and follow the standard usage. Eg..
import ( jww "github.com/spf13/jwalterweatherman" ) ... if err != nil { jww.ERROR.Println(err) } // this isn’t that important, but they may want to know jww.INFO.Printf("information %q", response)
By default:
The threshold can be changed at any time, but will only affect calls that execute after the change was made.
This is very useful if your application has a verbose mode. Of course you can decide what verbose means to you or even have multiple levels of verbosity.
import (
jww "github.com/spf13/jwalterweatherman"
)
if Verbose {
jww.SetLogThreshold(jww.LevelTrace)
jww.SetOutputThreshold(jww.LevelInfo)
}
JWW conveniently creates a temporary file and sets the log Handle to a io.Writer created for it. You should call this early in your application initialization routine as it will only log calls made after it is executed.
import (
jww "github.com/spf13/jwalterweatherman"
)
jww.UseTempLogFile("YourAppName")
JWW can log to any file you provide a path to (provided it’s writable). Will only append to this file.
import (
jww "github.com/spf13/jwalterweatherman"
)
jww.SetLogFile("/path/to/logfile")
This is an early release. I’ve been using it for a while and this is the third interface I’ve tried. I like this one pretty well, but no guarantees that it won’t change a bit.
I wrote this for use in hugo. If you are looking for a static website engine that’s super fast please checkout Hugo.