Faster-than-light, asynchronous, structured logger in Go with zero allocation count.
The following example creates a new logf
logger and logs a message.
package main
import (
"runtime"
"github.com/ssgreg/logf"
)
func main() {
// The default channel writer writes to stdout using json encoder.
writer, writerClose := logf.NewChannelWriter.Default()
defer writerClose()
logger := logf.NewLogger(logf.LevelInfo, writer)
logger.Info("got cpu info", logf.Int("count", runtime.NumCPU()))
}
The output is the following:
{"level":"info","ts":"2018-11-03T09:49:56+03:00","msg":"got cpu info","count":8}
TODO
Benchmarks:
- benchmarks descriptions
- non-parallel execution explanation
- scenario decomposition
- use zerolog object and array marshaller
- add checked logging for normal (not disabled) cases
Encoder:
- move to clone
- use EscapeString instead