Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kissaki/log4go
Logging package for Golang
https://github.com/kissaki/log4go
Last synced: 21 days ago
JSON representation
Logging package for Golang
- Host: GitHub
- URL: https://github.com/kissaki/log4go
- Owner: Kissaki
- License: bsd-2-clause
- Created: 2011-06-08T03:31:30.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-06-08T22:57:20.000Z (over 13 years ago)
- Last Synced: 2024-12-12T16:48:51.511Z (22 days ago)
- Language: Go
- Homepage:
- Size: 129 KB
- Stars: 1
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
log4go, forked from http://log4go.googlecode.com/ to apply fixes and patches, and to provide it with Git.
Installation
============Run
goinstall github.com/Kissaki/log4go
Usage
====Add the following import:
import l4g "github.com/Kissaki/log4go"
// Formatted logging can be done at any of the logging levels (Finest, Fine, Debug, Trace, Info, Warning, Error, Critical)
l4g.Trace("Received message: %s (%d)", msg, length)// Warnings, Errors, and Criticals provide an os.Error that you can use for a return
return l4g.Error("Unable to open file: %s", err)// The wrapper functions can also behave like Sprint if the first argument isn't a string
l4g.Debug(portno, clientid, client)// Use a closure so that if DEBUG isn't logged, it doesn't take any time
l4g.Debug(func()string{ decodeRaw(raw) })Log to a file:
l4g.AddFilter("file", l4g.NewFileLogWriter("myapp.log", false))
Using example/example.xml as a base you can use a configuration file to set up logging:
l4g.LoadConfiguration("logging.xml")