nrzap

package module
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilZapcore is an error caused by calling a WrapXCore function on a nil zapcore.Core object
	ErrNilZapcore = errors.New("cannot wrap nil zapcore.Core object")
	// ErrNilApp is an error caused by calling WrapBackgroundCore with a nil newrelic.Application
	ErrNilApp = errors.New("wrapped a zapcore.Core with a nil New Relic application; logs will not be captured")
	// ErrNilTxn is an error caused by calling WrapTransactionCore with a nil newrelic.Transaction
	ErrNilTxn = errors.New("wrapped a zapcore.Core with a nil New Relic transaction; logs will not be captured")
)

Functions

This section is empty.

Types

type NewRelicZapCore

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

NewRelicZapCore implements zap.Core

func WrapBackgroundCore

func WrapBackgroundCore(core zapcore.Core, app *newrelic.Application) (*NewRelicZapCore, error)

NewBackgroundCore creates a new NewRelicZapCore object, which is a wrapped zapcore.Core object. This wrapped object captures background logs in context and sends them to New Relic.

Errors will be returned if the zapcore object is nil, or if the application is nil. It is up to the user to decide how to handle the case where the newrelic.Application is nil. In the case that the newrelic.Application is nil, a valid NewRelicZapCore object will still be returned.

func WrapTransactionCore

func WrapTransactionCore(core zapcore.Core, txn *newrelic.Transaction) (*NewRelicZapCore, error)

WrapTransactionCore creates a new NewRelicZapCore object, which is a wrapped zapcore.Core object. This wrapped object captures logs in context of a transaction and sends them to New Relic.

Errors will be returned if the zapcore object is nil, or if the application is nil. It is up to the user to decide how to handle the case where the newrelic.Transaction is nil. In the case that the newrelic.Application is nil, a valid NewRelicZapCore object will still be returned.

func (NewRelicZapCore) Check

func (c NewRelicZapCore) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry

Check simply calls zapcore.Check on the Core object.

func (NewRelicZapCore) Enabled

func (c NewRelicZapCore) Enabled(level zapcore.Level) bool

Enabled simply calls zapcore.Enabled on the zapcore.Level passed to it.

func (NewRelicZapCore) Sync

func (c NewRelicZapCore) Sync() error

Sync simply calls zapcore.Sync on the Core object.

func (NewRelicZapCore) With

func (c NewRelicZapCore) With(fields []zap.Field) zapcore.Core

With makes a copy of a NewRelicZapCore with new zap.Fields. It calls zapcore.With() on the zap core object then makes a deepcopy of the NewRelicApplicationState object so the original object can be deallocated when it's no longer in scope.

func (NewRelicZapCore) Write

func (c NewRelicZapCore) Write(entry zapcore.Entry, fields []zap.Field) error

Write wraps zapcore.Write and captures the log entry and sends that data to New Relic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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