newrelic

package module
v0.0.0-...-29e4786 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 5 Imported by: 0

README

loggers-mapper-newrelic

Golang Loggers mapper for New Relic.

GoDoc Build Status

Pre-recquisite

See https://gopkg.in/birkirb/loggers.v1

Installation

go get github.com/adamhassel/loggers-mapper-newrelic

Usage

Assuming you are using loggers in your code, and you want to use loggers for New Relic. Start by configuring your loggers, and then pass it to the mapper and assign it as NewRelic's loggers interface.

Example
package main

import (
	"os"

    "gopkg.in/birkirb/loggers.v1"
	newrelic "github.com/newrelic/go-agent"
    nrlog "github.com/adamhassel/loggers-mapper-newrelic"
)

// Log is my default logger.
var Log loggers.Contextual

func main() {
	var debug bool
	if testing {
		debug = true
	}
	config := newrelic.NewConfig("myappname", license)
	logger := nrlog.NewLogger(Log, debug, true)
	config.Logger = logger
	app, err = newrelic.NewApplication(config)
	if err != nil {
		panic(err)
	}
	// ... do new relic transactions
}

Documentation

Overview

Package newrelic maps a birkirb/loggers to a newrelic.Logger

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultLogger

func NewDefaultLogger() newrelic.Logger

NewDefaultLogger returns a default Contextual Logger for birkirb's logger.

func NewLogger

func NewLogger(logger loggers.Contextual, debug, censor bool) newrelic.Logger

NewLogger converts birkirb's logger to a New Relic compatible logger. If censor, any new relic license is redacted from logs

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is an Contextual logger wrapper over Logrus's logger.

func (Logger) Debug

func (l Logger) Debug(msg string, fields map[string]interface{})

Debug logs newrelic debug messages

func (Logger) DebugEnabled

func (l Logger) DebugEnabled() bool

DebugEnabled returns whether debug is on

func (Logger) Error

func (l Logger) Error(msg string, fields map[string]interface{})

Error logs newrelic errors

func (Logger) Info

func (l Logger) Info(msg string, fields map[string]interface{})

Info logs newrelic info messages

func (Logger) Warn

func (l Logger) Warn(msg string, fields map[string]interface{})

Warn logs newrelic warnings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL