systemd_journal_h
.
Formatter for systemd_journal_h
.
This formatters formats data in the way that is digestible by the journald
.
fields :: [field_definition()]
Contains list of all fields that will be passed to the journald
.
Defaults to:
[message, syslog_timestamp, syslog_pid, syslog_priority, {"ERL_PID", pid}, {"CODE_FILE", file}, {"CODE_LINE", line}, {"CODE_MFA", mfa}]See Fields below.
report_cb :: fun ((Prefix :: field_name(), logger:report()) -> [field()]
Function that takes Prefix
and Logger's report and returns list of
values returned by systemd_journal_formatter:field/2
.
my_formatter(Prefix, #{field := Field}) when is_integer(Field) -> [ systemd_journal_formatter:field([Prefix,"_FIELD"], io_lib:format("~.16B", [Field]) ].Rememer that all field names MUST be uppercase and MUST NOT start with the underscore, otherwise
journald
can ignore them. Such
behaviour is not enforced on data returned by report_cb
and it is left
up to the user to the implementor to remember about it.time_designator :: byte()
Timestamps are formatted according to RFC3339, and the time designator is the character used as date and time separator.
Defaults to $T
.
calendar:system_time_to_rfc3339/2
.time_offset :: integer() | [byte()]
The time offset, either a string or an integer, to be used when formatting the timestamp.
An empty string is interpreted as local time. The values "Z", "z" or 0 are interpreted as Universal Coordinated Time (UTC).
Strings, other than "Z"
, "z"
, or ""
, must be on the form ±[hh]:[mm]
,
for example "-02:00"
or "+00:00"
.
Integers must be in microseconds, meaning that the offset 7200000000
is
equivalent to "+02:00"
.
Defaults to an "Z"
, meaning that timestamps are displayed in
UTC.
calendar:system_time_to_rfc3339/2
.Fields list contain definition of fields that will be presented in the log
message feeded into journald
. Few of them have special meaning and you can
see list of them in the
systemd.journal-fields(7)
manpage.
Metakeys (i.e. atoms and lists of atoms) in fields
list will be sent to
the journald
as a uppercased atom names, and in case of lists, joined
with underscores.
Entries in form of {Name :: field_name(), metakey()}
will use Name
as the field name. Name
will be checked if it is correct journald
field
name (i.e. contains only uppercase ASCII letters, digits, and underscores,
additionally do not start with underscore).
Entries in form of {Name :: field_name(), Data :: iolist()}
will use
Name
as field name and will contain Data
as a literal.
If entry data is empty or not set then it will be ommited in the output.
Special fields availables:
level
priority
msg
and message
os_pid
mfa
Module:Function/Arity
.time
Otherwise field is treated as a entry key where key
is equivalent of
[key]
and is used as a list of atoms to extract data from the metadata map.
To provide better compatibility and user convinience:
syslog_priority
{"SYSLOG_PRIORITY", priority}
.syslog_pid
{"SYSLOG_PID", os_pid}
.syslog_timestamp
{"SYSLOG_TIMESTAMP", time}
.syslog_facility
{"SYSLOG_FACILITY", facility}
.syslog_identifier
{"SYSLOG_TIMESTAMP", identifier}
.field() = {field_name(), iolist()}
field_definition() = metakey() | {field_name(), metakey() | iolist()}
field_name() = unicode:chardata()
metakey() = atom() | [atom()]
format_report/2 |
Default report formatter used for systemd_journal_formatter . |
format_report(Prefix::field_name(), Report::logger:report()) -> [field()]
Default report formatter used for systemd_journal_formatter
. Output format
will be similar to one provided by logger:format_report/1
, but this one
takes also additional parameter Perfix
which should be used as prefix for
all generated fields.
Generated by EDoc