journallog

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package journallog sends logrus entries to journald over its native protocol, so each line keeps its priority and logrus fields become journal fields. Plain stderr lines are all stored at priority info, which would hide warnings from a `journalctl -p warning` reader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldName

func FieldName(key string) string

FieldName turns a logrus field key into a valid journal field name: uppercase, characters outside A-Z, 0-9 and _ replaced by _, and leading underscores dropped so a field can't pose as a trusted one. It returns "" for keys that can't be used.

func Install

func Install() bool

Install routes the standard logger to journald when stderr is connected to the journal (the process runs under systemd) and reports whether it did. Otherwise logging stays on stderr, e.g. under `make dev` and in tests.

func Priority

func Priority(l logrus.Level) journal.Priority

Priority maps a logrus level to a syslog priority.

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook is a logrus hook writing every entry to journald.

func New

func New() *Hook

func (*Hook) Fire

func (h *Hook) Fire(e *logrus.Entry) error

func (*Hook) Levels

func (h *Hook) Levels() []logrus.Level

type SendFunc

type SendFunc func(message string, priority journal.Priority, vars map[string]string) error

SendFunc matches journal.Send.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL