GithubHelp home page GithubHelp logo

hirosassa / zerodriver Goto Github PK

View Code? Open in Web Editor NEW
30.0 2.0 9.0 35 KB

Zerolog based logging library optimized for Cloud Logging (formerly Stackdriver Logging)

License: MIT License

Go 100.00%
zerolog google-cloud cloud-logging cloud-trace structured-logging golang

zerodriver's Issues

feature request: sentry integration

I think it's common pattern that logging error and sending events to monitoring service like Sentry, when an error happens.

so it's nice if this logger support sentry, like https://github.com/archdx/zerolog-sentry

some requirements image:

  • can enable/disable sentry sending per each .Msg() call
  • automatically set sentry event's error level according to logger's error level
  • works with sentry's additional package like https://docs.sentry.io/platforms/go/guides/http/ (automatically set http request info to sentry events)
  • automatically set logger's label data to sentry events

Logging API behavior for error differs

The *.err(err Error) API from zerodriver is not behaving like the one from zerolog.

The execution of the following command

package main

import (
	"github.com/hirosassa/zerodriver"
	"github.com/rs/zerolog/log"
)

func main() {
	driverLog := *zerodriver.NewProductionLogger()
	log.Logger = *driverLog.Logger
	driverLog.Err(nil).Msg("error")
	log.Err(nil).Msg("error")
}

is

{"severity":"ERROR","time":"2022-12-02T16:16:39.642678263+01:00","message":"error"}
{"severity":"INFO","time":"2022-12-02T16:16:39.642704011+01:00","message":"error"}

This is the result of the usage of the wrong API in the abstraction layer at:

e := l.Logger.Error().Err(err)

Which should be replaced with

e := l.Logger.Err(err)

Proposal: use Labels command more than once

Currently, Labels returns *zerolog.Event. So, we can't call Labels command more than once.
I want to do it as follows.
Do you think about this?

// prepare common label
commonLogger := logger.Info().Labels(zerodriver.Label("label", "common"))

commonLogger.Labels("phase", "1").Msg("hoge")
commonLogger.Labels("phase", "2").Msg("fuga")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.