Libraries
glog
A concurrent, thread-safe logger for Go.
Why it existsLogging from many goroutines shouldn't need hand-rolled locking. glog is safe to call from anywhere and outputs plain text or structured JSON with one line of setup.
Simple interfaces for fast, safe logging from many goroutines, in plain text or structured JSON.
- Stars
- 1 stars
- Forks
- 0 forks
- Last push
- Updated 5 years ago
Languages
Go100.0%
README.md
Glog
Glog glugs the log files in a concurrent and thread-safe way.
Simple and easy to implement interfaces to log fast and efficiently
Features
- Thread-safe logger
- Log formatting support
- Logging in unstructured or structured format (JSON)
Usage
go get github.com/ric-v/glog
simple logger to stdout
package main
import "github.com/ric-v/glog"
func main() {
defer glog.Cleanup()
// log the message to the default concurrent logger
glog.Info("Hello World")
}
json logger to file
package main
import "github.com/ric-v/glog"
func main() {
logger := glog.JSONGlogger("glogger.log")
defer logger.Cleanup()
// log the message to custom json logger
logger.Info("", "Hello", "World")
}
Benchmarks
| Benchmark | Iterations | Time | Size | Allocation |
|---|---|---|---|---|
| BenchmarkJSONGlog | 266092 | 3853 ns/op | 2185 B/op | 25 allocs/op |
| BenchmarkUnstructureGlog_log | 412342 | 3054 ns/o | 984 B/op | 13 allocs/op |
Examples
visit examples here
Code.Share.Prosper