Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support to ZeroLog #150

Closed
matheus-meneses opened this issue May 23, 2020 · 4 comments
Closed

Add Support to ZeroLog #150

matheus-meneses opened this issue May 23, 2020 · 4 comments
Assignees
Labels

Comments

@matheus-meneses
Copy link

Hi guys,
Is there a roadmap to introduce support to https://github.com/rs/zerolog ?

Regards

@jodeev
Copy link
Contributor

jodeev commented May 29, 2020

@matheus-meneses - thanks for this input. Can you confirm that you mean that we add support for the go-agent to send its log messages to zerolog?

@jodeev jodeev self-assigned this Jul 9, 2020
@belimawr
Copy link

I'm curious about is as well as we heavily use zerolog at OneFootball. For the go-agent to log using zerolog I did a very simple wrapper:

import "github.com/rs/zerolog"

const prefix = "_newrelic_agent_"

type nrLogger struct {
	l zerolog.Logger
}

func (l nrLogger) Error(msg string, context map[string]interface{}) {
	l.l.Error().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) Warn(msg string, context map[string]interface{}) {
	l.l.Warn().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) Info(msg string, context map[string]interface{}) {
	l.l.Info().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) Debug(msg string, context map[string]interface{}) {
	l.l.Debug().Fields(sanitiseLogKeys(context)).Msg(msg)
}

func (l nrLogger) DebugEnabled() bool {
	return l.l.Debug().Enabled()
}

func sanitiseLogKeys(m map[string]interface{}) map[string]interface{} {
	final := make(map[string]interface{}, len(m))

	for k, v := range m {
		final[prefix+k] = v
	}

	return final
}

It also prefixes all keys from the go-agent to avoid collision with our own log keys.

Is that what you're looking for @matheus-meneses ?

It would be awesome to have it as part of the go-agent.

@RichVanderwal
Copy link
Contributor

We're taking a look at the input above, as well as the plugin to support it with a view to putting it into the next release of the Go Agent. Let us know if you have any other comments or suggestions!

@iamemilio
Copy link
Contributor

iamemilio commented Apr 20, 2022

I am closing this issue to consolidate tickets about zerolog logs in context. We are still planning this work, but will now track it from the ticket that is already on our roadmap: #178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants