/goplogjson

Primary LanguageGoMIT LicenseMIT

Go Reference Go Report Card codecov Pipeline

Contributors Forks Stargazers Issues MIT License


Gop Log Json

A json implementation for [gop log](https://github.com/axpira/gop) with zero allocation
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Installation
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

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

(back to top)

Built With

  • Golang
  • Zero allocation
  • No external lib

(back to top)

Installation

go get -u github.com/axpira/goplogjson

(back to top)

Usage

Just import in your project and use GOP Log, and the output log will be a JSON

import (
	_ "github.com/axpira/goplogjson"
)

Customize

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

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Thiago Ferreira - thiagogbferreira@gmail.com

Project Link: https://github.com/axpira/goplogjson

(back to top)