Skip to content

32bitkid/clog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

clog

Simple conditional logging for go.

See the documentation.

Installation

$ go get github.com/32bitkid/clog

Examples

clog is silent by default...

log := NewLog("package")
log.Println("This is a log")
fmt.Println("<end>")
$ go run test.go
<end>

...but can easily be configured to show all registered loggers...

log := NewLog("package")

log.Println("This is a log")
fmt.Println("<end>")
$ DEBUG=* go run test.go
package: This is a log!
<end>

...or only show logs from a specific namespace...

 foolog := NewLog("foo")
 barlog := NewLog("bar")
 foolog.Println("This is a log")
 barlog.Println("This is a log")
 fmt.Println("<end>")
$ DEBUG=foo go run test.go
foo: This is a log
<end>

...and even match namespaces with wildcards.

barlog := NewLog("foo:bar")
bazlog := NewLog("foo:baz")
quxlog := NewLog("qux")

barlog.Println("This is a log")
bazlog.Println("This is a log")
quxlog.Println("This is a log")

fmt.Println("<end>")
$ DEBUG=foo:* go run test.go
foo:bar This is a log
foo:baz This is a log
<end>

About

A simple conditional logger for go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages