azer / logger Goto Github PK
View Code? Open in Web Editor NEWMinimalistic logging library for Go.
Home Page: http://godoc.org/github.com/azer/logger
License: Do What The F*ck You Want To Public License
Minimalistic logging library for Go.
Home Page: http://godoc.org/github.com/azer/logger
License: Do What The F*ck You Want To Public License
Running the example code:
package main
import (
"github.com/azer/logger"
"time"
)
var log = logger.New("app")
func main() {
log.Info("Starting at %d", 9088)
log.Info("Requesting an image at foo/bar.jpg")
timer := log.Timer()
time.Sleep(time.Millisecond * 250)
timer.End("Fetched foo/bar.jpg")
log.Error("Failed to start, shutting down...")
}
with version 71c896b
yields the following error:
panic: assignment to entry in nil map
goroutine 1 [running]:
panic(0xc58e0, 0xc820064050)
/usr/local/go/src/runtime/panic.go:464 +0x3e6
/vendor/github.com/azer/logger.New(0x10baf8, 0x3, 0xc820050000)
/vendor/github.com/azer/logger/logger.go:26 +0xaa
main.init()
/example.go:8 +0x65
exit status 2
Reverting to d8432cee
resolves the issue:
11:39:22.887 app: Starting at 9088
11:39:22.887 app: Requesting an image at foo/bar.jpg
11:39:23.142 app(254.627113ms): Fetched foo/bar.jpg
11:39:23.142 app(!): Failed to start, shutting down...
Official log package provides SetOutput(w io.Writer)
for change writer os.Stderr to another.
Hey, this logger looks great- a good blend of simple API, levelling/app-segregation, and nice design.
One feature I'd really like, though, is the ability to programmatically enable logs and log levels, rather than relying on the environment variable method. If I'm already defining a CLI interface for my application I'd prefer to add a "-v" / "-vv" flag to enable various log levels or log types.
It looks like this would be easy to do if the "enabled" map were exposed publicly. Alternatively, if a setter function were added to complement IsEnabled
, so you could call a function with a logger name and a state to enable. Something like SetEnabled(logname string, setstate bool) error
.
I can write it up and PR, if you like?
Hello, under what license is this project released under ? Thank-you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.