Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DontFallback = false
DontFallback disables printing failed logs to FallbackWriter (set FallbackWriter nil to disable completely)
var DontLogErrors = false
DontLogErrors disables printing errors to FallbackWriter
var ErrVarNameEmpty = errors.New("empty variable name")
var ErrVarNameInvalid = errors.New("variable name contains invalid characters")
var ErrVarNameUnderscore = errors.New("variable name begins with an underscore")
var FallbackWriter = os.Stderr
FallbackWriter is used when writing to journal fails
If nil, write fails will be silent.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled checks whether the local systemd journal is available for logging.
func GetJournalOrStderr ¶
GetJournalOrStderr checks if journal is enabled.
if not, returns os.Stderr
If p is zero, uses INFO level
func Send ¶
Send a message to the local systemd journal. vars is a map of journald fields to values. Fields must be composed of uppercase letters, numbers, and underscores, but must not start with an underscore. Within these restrictions, any arbitrary field name may be used. Some names have special significance: see the journalctl documentation (http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html) for more details. vars may be nil.
Types ¶
type JournalWriter ¶
type JournalWriter struct {
Priority // default 0 is 'Emergency' level
}
JournalWriter writes to the systemd journal. If journal is not available, it falls back to FallbackWriter. It's an io.Writer, and log.SetOutput() can be used to set it as the default logger.
var Info = JournalWriter{journal.PriInfo} var Err = JournalWriter{journal.PriErr} var Debug = JournalWriter{journal.PriDebug} var Warning = JournalWriter{journal.PriWarning} var Emergency = JournalWriter{journal.PriEmerg} var Alert = JournalWriter{journal.PriAlert} var Critical = JournalWriter{journal.PriCrit} var Notice = JournalWriter{journal.PriNotice}