Documentation
¶
Overview ¶
Package sentrylogrus provides a simple Logrus hook for Sentry.
Index ¶
- Constants
- type FallbackFunc
- type Hook
- func New(levels []logrus.Level, opts sentry.ClientOptions) (Hook, error)deprecated
- func NewEventHook(levels []logrus.Level, opts sentry.ClientOptions) (Hook, error)deprecated
- func NewEventHookFromClient(levels []logrus.Level, client *sentry.Client) Hookdeprecated
- func NewFromClient(levels []logrus.Level, client *sentry.Client) Hookdeprecated
- func NewLogHook(levels []logrus.Level, opts sentry.ClientOptions) (Hook, error)
- func NewLogHookFromClient(levels []logrus.Level, client *sentry.Client) Hook
Constants ¶
const ( // FieldRequest holds an *http.Request. FieldRequest = "request" // FieldUser holds a User or *User value. FieldUser = "user" // FieldTransaction holds a transaction ID as a string. FieldTransaction = "transaction" // FieldFingerprint holds a string slice ([]string), used to dictate the // grouping of this event. FieldFingerprint = "fingerprint" // These fields are simply omitted, as they are duplicated by the Sentry SDK. FieldGoVersion = "go_version" FieldMaxProcs = "go_maxprocs" LogrusOrigin = "auto.log.logrus" )
These default log field keys are used to pass specific metadata in a way that Sentry understands. If they are found in the log fields, and the value is of the expected datatype, it will be converted from a generic field, into Sentry metadata.
These keys may be overridden by calling SetKey on the hook object.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FallbackFunc ¶
A FallbackFunc can be used to attempt to handle any errors in logging, before resorting to Logrus's standard error reporting.
type Hook ¶
type Hook interface {
// SetHubProvider sets a function to provide a hub for each log entry.
SetHubProvider(provider func() *sentry.Hub)
// AddTags adds tags to the hook's scope.
AddTags(tags map[string]string)
// SetFallback sets a fallback function for the eventHook.
SetFallback(fb FallbackFunc)
// SetKey sets an alternate field key for the eventHook.
SetKey(oldKey, newKey string)
// Levels returns the list of logging levels that will be sent to Sentry as events.
Levels() []logrus.Level
// Fire sends entry to Sentry as an event.
Fire(entry *logrus.Entry) error
// Flush waits until the underlying Sentry transport sends any buffered events.
Flush(timeout time.Duration) bool
// FlushWithContext waits for the underlying Sentry transport to send any buffered
// events, blocking until the context's deadline is reached or the context is canceled.
// It returns false if the context is canceled or its deadline expires before the events
// are sent, meaning some events may not have been sent.
FlushWithContext(ctx context.Context) bool
}
Hook is the logrus hook for Sentry.
It is not safe to configure the hook while logging is happening. Please perform all configuration before using it.
func New
deprecated
Deprecated: New creates issues/events from log entries. Errors should only be captured using sentry.CaptureException instead of being converted from log entries. Use NewLogHook for structured logging. Will be removed in 0.48.0.
func NewEventHook
deprecated
added in
v0.34.0
Deprecated: NewEventHook creates issues/events from log entries. Errors should only be captured using sentry.CaptureException instead of being converted from log entries. Use NewLogHook for structured logging. Will be removed in 0.48.0.
func NewEventHookFromClient
deprecated
added in
v0.34.0
Deprecated: NewEventHookFromClient creates issues/events from log entries. Errors should only be captured using sentry.CaptureException instead of being converted from log entries. Use NewLogHookFromClient for structured logging. Will be removed in 0.48.0.
func NewFromClient
deprecated
Deprecated: NewFromClient creates issues/events from log entries. Errors should only be captured using sentry.CaptureException instead of being converted from log entries. Use NewLogHookFromClient for structured logging. Will be removed in 0.48.0.
func NewLogHook ¶ added in v0.34.0
NewLogHook initializes a new Logrus hook which sends logs to a new Sentry client configured according to opts.