Documentation ¶
Overview ¶
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0 agent domain features
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0 package log is our own log package, basically a wrapper for logrus with some improvements like: - lazy evaluation of WithFields funcs - shrinked logrus API (no Fatal, Panic...) - added agent domain API helpers like CustomIntegration/... this file was based on logrus/exported.go
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0 package log provides a log wrapper to be used within the agent. It implements a Functional Logger Facade on top of Logrus. It aims at keeping conciseness without losing performance when composite loggers are built (WithError, WithFields...), making the related methods to be invoked lazily, avoiding to consume CPU resources if those are not going to be used (e.g. we won't generate a WithFields(...) logger entry if it is for debugging and the log level is Info.
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func AddHook(hook logrus.Hook)
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func EnableSmartVerboseMode(cachedEntryLimit int)
- func EnableTemporaryVerbose()
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func GetFormatter() logrus.Formatter
- func GetLevel() logrus.Level
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Instrument(m instrumentation.Measure)
- func IsLevelEnabled(level logrus.Level) bool
- func NewStdoutTeeLogger(writer io.Writer, stdout bool) io.Writer
- func ParseLevel(lvl string) (logrus.Level, error)
- func SetFormatter(formatter logrus.Formatter)
- func SetLevel(level logrus.Level)
- func SetOutput(out io.Writer)
- func Trace(args ...interface{})
- func Tracef(format string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- type Entry
- func WithComponent(name string) Entry
- func WithError(err error) Entry
- func WithField(key string, value interface{}) Entry
- func WithFields(f logrus.Fields) Entry
- func WithFieldsF(lff func() logrus.Fields) Entry
- func WithIntegration(name string) Entry
- func WithPlugin(name string) Entry
- func WithTraceField(key string, value interface{}) Entry
- func WithTraceFields(f logrus.Fields) Entry
- func WithTraceFieldsF(lff func() logrus.Fields) Entry
- func (e Entry) Debug(msg string)
- func (e Entry) Debugf(format string, args ...interface{})
- func (e Entry) Error(msg string)
- func (e Entry) Errorf(format string, args ...interface{})
- func (e Entry) Fields() logrus.Fields
- func (e Entry) Info(msg string)
- func (e Entry) Infof(format string, args ...interface{})
- func (e Entry) IsDebugEnabled() bool
- func (e Entry) IsWarnEnabled() bool
- func (e Entry) Trace(msg string)
- func (e Entry) Tracef(format string, args ...interface{})
- func (e Entry) Warn(msg string)
- func (e Entry) Warnf(format string, args ...interface{})
- func (e Entry) WithComponent(name string) Entry
- func (e Entry) WithError(err error) Entry
- func (e Entry) WithField(key string, value interface{}) Entry
- func (e Entry) WithFields(f logrus.Fields) Entry
- func (e Entry) WithFieldsF(lff func() logrus.Fields) Entry
- func (e Entry) WithIntegration(name string) Entry
- func (e Entry) WithPlugin(name string) Entry
- func (e Entry) WithTraceField(key string, value interface{}) Entry
- func (e Entry) WithTraceFields(f logrus.Fields) Entry
- func (e Entry) WithTraceFieldsF(lff func() logrus.Fields) Entry
- type FileWithRotation
- type FileWithRotationConfig
- type MemLogger
Constants ¶
const DefaultVerboseMin = 5
DefaultVerboseMin default verbose time range in minutes.
Variables ¶
var ErrFileNotOpened = errors.New("cannot perform operation, file is not opened")
ErrFileNotOpened is returned when an operation cannot be performed because the file is not opened.
Functions ¶
func Debug ¶
func Debug(args ...interface{})
Debug logs a message at level Debug on the standard logger.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a message at level Debug on the standard logger.
func EnableSmartVerboseMode ¶
func EnableSmartVerboseMode(cachedEntryLimit int)
func EnableTemporaryVerbose ¶
func EnableTemporaryVerbose()
EnableTemporaryVerbose enables verbose logging for a given amount of minutes.
func Error ¶
func Error(args ...interface{})
Error logs a message at level Error on the standard logger.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a message at level Error on the standard logger.
func Info ¶
func Info(args ...interface{})
Info logs a message at level Info on the standard logger.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a message at level Info on the standard logger.
func Instrument ¶
func Instrument(m instrumentation.Measure)
func IsLevelEnabled ¶
IsLevelEnabled checks if the log level of the standard logger is greater than the level param
func NewStdoutTeeLogger ¶
NewStdoutTeeLogger return an io.Writer that can redirect to stdout if needed.
func ParseLevel ¶
ParseLevel takes a string level and returns the Logrus log level constant. Same implementation as logrus adding custom "smart" level mapping to debug.
func SetFormatter ¶
SetFormatter sets the standard logger formatter.
func Trace ¶
func Trace(args ...interface{})
Trace logs a message at level Trace on the standard logger.
func Tracef ¶
func Tracef(format string, args ...interface{})
Tracef logs a message at level Trace on the standard logger.
func Warn ¶
func Warn(args ...interface{})
Warn logs a message at level Warn on the standard logger.
Types ¶
type Entry ¶
Entry is a functional wrapper for the logrus.Entry type
func WithComponent ¶
WithComponent decorates log context with integration name
func WithFields ¶
func WithFieldsF ¶
func WithIntegration ¶
WithIntegration decorates log context with integration name
func WithPlugin ¶
WithPlugin decorates log context with plugin name
func WithTraceField ¶
func WithTraceFields ¶
func WithTraceFieldsF ¶
func (Entry) IsDebugEnabled ¶
func (Entry) IsWarnEnabled ¶
func (Entry) WithComponent ¶
WithComponent decorates entry context with integration name
func (Entry) WithIntegration ¶
WithIntegration decorates entry context with integration name
func (Entry) WithPlugin ¶
WithPlugin decorates entry context with plugin name
func (Entry) WithTraceField ¶
func (Entry) WithTraceFields ¶
Fields will be only added if TraceLevel is enabled
type FileWithRotation ¶
FileWithRotation decorates a file with rotation mechanism. The current file will be rotated before Write(ing) new content if that will cause exceeding the configured max bytes. The rotated file will get the name from the provided pattern in the configuration. If rotation fails, we will continue to write to the current log file to avoid losing data.
Global logger should not be called within the synchronous methods of FileWithRotation since it can lead to a deadlock. Global logger can be called from Asynchronous code.
func NewFileWithRotation ¶
func NewFileWithRotation(cfg FileWithRotationConfig) *FileWithRotation
NewFileWithRotation creates a new FileWithRotation.
func (*FileWithRotation) Open ¶
func (f *FileWithRotation) Open() (*FileWithRotation, error)
Open the file to write in. If the file doesn't exist, a new file will be created.
type FileWithRotationConfig ¶
type FileWithRotationConfig struct { File string FileNamePattern string MaxSizeInBytes int64 Compress bool MaxFiles int }
FileWithRotationConfig keeps the configuration for a new FileWithRotation.
type MemLogger ¶
type MemLogger struct {
// contains filtered or unexported fields
}