Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportPanic ¶
func ReportPanic(token, env string)
ReportPanic attempts to report the panic to rollbar if the token is set
func SetupLogging ¶
SetupLogging sets up logging. If token is not an empty string a rollbar hook is added with the environment set to env. The log formatter is set to a TextFormatter with timestamps disabled, which is suitable for use on Heroku.
Example ¶
SetupLogging("some-long-token", "staging") // This will not be reported to Rollbar logrus.Info("OHAI") // This will be reported to Rollbar logrus.WithFields(logrus.Fields{"hi": "there"}).Fatal("The end.")
Output:
func SetupLoggingForLevels ¶
func SetupLoggingForLevels(token, env string, config RollrusConfig) io.Closer
SetupLoggingForLevels works like SetupLogging, but allows you to set the levels on which to trigger this hook.
Types ¶
type Hook ¶
Hook wrapper for the rollbar Client May be used as a rollbar client itself
func NewHook ¶
Setup a new hook with default reporting levels, useful for adding to your own logger instance.
Example ¶
log := logrus.New() hook := NewHook("my-secret-token", "production") log.Hooks.Add(hook) // This will not be reported to Rollbar log.WithFields(logrus.Fields{"power_level": "9001"}).Debug("It's over 9000!") // This will be reported to Rollbar log.Panic("Boom.")
Output:
func NewHookForLevels ¶
func NewHookForLevels(token string, env string, config RollrusConfig) *Hook
Setup a new hook with specified reporting levels, useful for adding to your own logger instance.
func (*Hook) Fire ¶
Fire the hook. This is called by Logrus for entries that match the levels returned by Levels(). See below.
func (*Hook) ReportPanic ¶
func (r *Hook) ReportPanic()
ReportPanic attempts to report the panic to rollbar using the provided client and then re-panic. If it can't report the panic it will print an error to stderr.