Documentation
¶
Overview ¶
Package entry is the log behavior: the entries of the systemd journal of the host, read with journalctl on each Linux host. The Go package keeps the name entry, so it does not hide the standard library's log.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Behavior = behavior.Register(behavior.Define( "log", "The entries of the systemd journal", behavior.Node, behavior.API, behavior.Area(area.Logs), behavior.CLI, behavior.Platform(behavior.PlatformLinux, newLinux), behavior.Read("list", List). NotAFact("the entries are what journald holds now, not a fact of the host"). Runs("journalctl"). Describe("List the entries of the journal"). Explain("Runs journalctl --output=json, the newest entries last: the last "+ "100 unless lines says, of one unit when unit says, since a time when "+ "since says, and at a priority or above when priority says. A priority "+ "is its name, such as err or info. The hand-written log domain read the "+ "Debian family only; this reads each Linux host that has journald."). Example("The newest entries", ListInput{}, []Entry{nginxEntry, sshdEntry}, behavior.Prints("journalctl --output=json -n 100", nginx+"\n"+sshd+"\n"), ). Example("The last entry of one unit at info or above", ListInput{Unit: "nginx.service", Lines: 1, Since: "1 hour ago", Priority: "info"}, []Entry{nginxEntry}, behavior.Prints( "journalctl --output=json --unit=nginx.service --since=1 hour ago --priority=info -n 1", nginx+"\n", ), ). Fails("Lines below one", ListInput{Lines: -1}, "min"). Fails("More than 10000 lines", ListInput{Lines: 10001}, "max"). Fails("A priority that journald does not have", ListInput{Priority: "loud"}, "enum"). Fails("A unit with a space in it", ListInput{Unit: "nginx service"}, "unit_name"), ))
Behavior is the entries of the systemd journal. They are what journald holds now, not a fact of the host, so journalctl reads them, not gohai. It runs on each Linux host; macOS has no journal, and reports skipped.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Timestamp string `json:"timestamp" doc:"When journald recorded it, in RFC 3339"`
Unit string `json:"unit,omitempty" doc:"The syslog identifier that wrote it"`
Priority Priority `json:"priority,omitempty" doc:"Its priority, by name. An entry that journald has no priority for has none"`
Message string `json:"message" doc:"The message"`
PID int `json:"pid,omitempty" doc:"The process that wrote it"`
}
Entry is one entry of the journal.
type ListInput ¶
type ListInput struct {
Unit string `` /* 129-byte string literal not displayed */
Lines int `json:"lines,omitempty" validate:"omitempty,min=1,max=10000" doc:"How many of the newest entries; 100 when it is not set"`
Since string `` /* 164-byte string literal not displayed */
Priority Priority `json:"priority,omitempty" validate:"omitempty,enum" doc:"Only the entries at this priority or above"`
}
ListInput selects the entries: each field is a query parameter and a flag.
type Priority ¶
type Priority string
Priority is the priority of a journal entry, by the name that journald gives it.
const ( PriorityEmerg Priority = "emerg" PriorityAlert Priority = "alert" PriorityCrit Priority = "crit" PriorityErr Priority = "err" PriorityWarning Priority = "warning" PriorityNotice Priority = "notice" PriorityInfo Priority = "info" PriorityDebug Priority = "debug" )
The priorities of journald, from the highest.
func Priorities ¶
func Priorities() []Priority
Priorities are the priorities in journald's order: the index of each is its number, 0 for emerg to 7 for debug.