Documentation ¶
Overview ¶
Package sentrylogrus provides a simple Logrus hook for Sentry.
Index ¶
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" )
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 struct {
// contains filtered or unexported fields
}
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 ¶
New initializes a new Logrus hook which sends logs to a new Sentry client configured according to opts.
func NewFromClient ¶
NewFromClient initializes a new Logrus hook which sends logs to the provided sentry client.
func (*Hook) Flush ¶
Flush waits until the underlying Sentry transport sends any buffered events, blocking for at most the given timeout. It returns false if the timeout was reached, in which case some events may not have been sent.
func (*Hook) SetFallback ¶
func (h *Hook) SetFallback(fb FallbackFunc)
SetFallback sets a fallback function, which will be called in case logging to sentry fails. In case of a logging failure in the Fire() method, the fallback function is called with the original logrus entry. If the fallback function returns nil, the error is considered handled. If it returns an error, that error is passed along to logrus as the return value from the Fire() call. If no fallback function is defined, a default error message is returned to Logrus in case of failure to send to Sentry.