nrslog

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

v3/integrations/nrslog GoDoc

Package nrslog supports log/slog.

import "github.com/newrelic/go-agent/v3/integrations/nrslog"

For more information, see godocs.

Documentation

Overview

Package nrslog supports `log/slog`

Wrap your slog Logger using nrslog.Transform to send agent log messages to standard log library.

Example
package main

import (
	"log/slog"

	"github.com/newrelic/go-agent/v3/integrations/nrslog"
	"github.com/newrelic/go-agent/v3/newrelic"
)

func main() {
	// Get the default logger or create a new one:
	l := slog.Default()

	_, err := newrelic.NewApplication(
		newrelic.ConfigAppName("Example App"),
		newrelic.ConfigLicense("__YOUR_NEWRELIC_LICENSE_KEY__"),
		// Use nrslog to register the logger with the agent:
		nrslog.ConfigLogger(l.WithGroup("newrelic")),
	)
	if err != nil {
		panic(err)
	}
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigLogger

func ConfigLogger(l *slog.Logger) newrelic.ConfigOption

ConfigLogger configures the newrelic.Application to send log messages to the provided slog.

func Transform

func Transform(l *slog.Logger) newrelic.Logger

Transform turns a *slog.Logger into a newrelic.Logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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