Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrToMsg ¶
ErrToMsg sets Message to the contents of the associated error, if Message is not already set.
Default journalctl output will only show the contents of the `MESSAGE` field. If the message is empty but the entry has an associated error, we replace the message with the contents of the error so that it is shown in the journalctl output by default.
This makes it possible to use `log.WithError(err).Error()` without providing an additional error message.
If a string is passed to `Error` function, this is used as the message.
func NormalizeFieldName ¶
NormalizeFieldName returns field name acceptable by journald.
Types ¶
type JournalHook ¶
JournalHook is the systemd-journald hook for logrus.
func NewJournalHook ¶
func NewJournalHook() (*JournalHook, error)
NewJournalHook creates a hook to be added to an instance of logger.
func NewJournalHookWithErrToMsg ¶
func NewJournalHookWithErrToMsg() (hook *JournalHook, err error)
NewJournalHookWithErrToMsg creates a hook, which converts associated errors to messages, to be added to an instance of logger
func NewJournalHookWithLevels ¶
func NewJournalHookWithLevels(levels []logrus.Level) (*JournalHook, error)
NewJournalHookWithLevels creates a hook to be added to an instance of logger. It's also allowed to specify logrus levels to fire events for.
func (*JournalHook) Fire ¶
func (h *JournalHook) Fire(entry *logrus.Entry) error
Fire writes a log entry to the systemd journal.
func (*JournalHook) Levels ¶
func (h *JournalHook) Levels() []logrus.Level
Levels returns a slice of Levels the hook is fired for.