A json implementation for [gop log](https://github.com/axpira/gop) with zero allocation
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
A fast and with zero allocation implementation for gop log.
And no external depency, everything using builtin in Golang.
Output format is JSON and is very configurable
The main ideia is for ZeroLog
- Golang
- Zero allocation
- No external lib
go get -u github.com/axpira/goplogjson
Just import in your project and use GOP Log, and the output log will be a JSON
import (
_ "github.com/axpira/goplogjson"
)
package main
import (
"errors"
"time"
"github.com/axpira/gop/log"
glj "github.com/axpira/goplogjson"
)
func main() {
glj.DurationFieldUnit = time.Hour
glj.ErrorFieldName = "myfielderr"
glj.LevelFieldName = "mygreatlevel"
glj.MessageFieldName = "mymessage"
glj.TimeFormat = time.RFC1123
glj.TimestampEnabled = false
log.Log(
log.ErrorLevel,
log.Msg("Hello World").Err(errors.New("unknown error")),
)
// Output: {"mymessage":"Hello World","myfielderr":"unknown error","mygreatlevel":"error"}
For more examples, please refer to the GOP Log
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Thiago Ferreira - thiagogbferreira@gmail.com
Project Link: https://github.com/axpira/goplogjson