core: append LogExtraFields= values to log_unit* messages
This ensure messages from PID1 regarding a unit also contain those fields. For example, portable services have PORTABLE=<image> as extra fields, which is useful to identify which version of a portable image produced a log message like an error or an oomd kill.
This commit is contained in:
@@ -2909,8 +2909,8 @@ StandardInputData=V2XigLJyZSBubyBzdHJhbmdlcnMgdG8gbG92ZQpZb3Uga25vdyB0aGUgcnVsZX
|
||||
<term><varname>LogExtraFields=</varname></term>
|
||||
|
||||
<listitem><para>Configures additional log metadata fields to include in all log records generated by
|
||||
processes associated with this unit. This setting takes one or more journal field assignments in the
|
||||
format <literal>FIELD=VALUE</literal> separated by whitespace. See
|
||||
processes associated with this unit, including systemd. This setting takes one or more journal field
|
||||
assignments in the format <literal>FIELD=VALUE</literal> separated by whitespace. See
|
||||
<citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
|
||||
for details on the journal field concept. Even though the underlying journal implementation permits
|
||||
binary field values, this setting accepts only valid UTF-8 values. To include space characters in a
|
||||
|
||||
+20
-3
@@ -1078,7 +1078,13 @@ Condition *unit_find_failed_condition(Unit *u);
|
||||
({ \
|
||||
const Unit *_u = (unit); \
|
||||
const int _l = (level); \
|
||||
(log_get_max_level() < LOG_PRI(_l) || (_u && !unit_log_level_test(_u, _l))) ? -ERRNO_VALUE(error) : \
|
||||
bool _do_log = !(log_get_max_level() < LOG_PRI(_l) || \
|
||||
(_u && !unit_log_level_test(_u, _l))); \
|
||||
const ExecContext *_c = _do_log && _u ? \
|
||||
unit_get_exec_context(_u) : NULL; \
|
||||
LOG_CONTEXT_PUSH_IOV(_c ? _c->log_extra_fields : NULL, \
|
||||
_c ? _c->n_log_extra_fields : 0); \
|
||||
!_do_log ? -ERRNO_VALUE(error) : \
|
||||
_u ? log_object_internal(_l, error, PROJECT_FILE, __LINE__, __func__, _u->manager->unit_log_field, _u->id, _u->manager->invocation_log_field, _u->invocation_id_string, ##__VA_ARGS__) : \
|
||||
log_internal(_l, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
|
||||
})
|
||||
@@ -1116,7 +1122,12 @@ Condition *unit_find_failed_condition(Unit *u);
|
||||
({ \
|
||||
const Unit *_u = (unit); \
|
||||
const int _l = (level); \
|
||||
unit_log_level_test(_u, _l) ? \
|
||||
bool _do_log = unit_log_level_test(_u, _l); \
|
||||
const ExecContext *_c = _do_log && _u ? \
|
||||
unit_get_exec_context(_u) : NULL; \
|
||||
LOG_CONTEXT_PUSH_IOV(_c ? _c->log_extra_fields : NULL, \
|
||||
_c ? _c->n_log_extra_fields : 0); \
|
||||
_do_log ? \
|
||||
log_struct_errno(_l, error, __VA_ARGS__, LOG_UNIT_ID(_u)) : \
|
||||
-ERRNO_VALUE(error); \
|
||||
})
|
||||
@@ -1125,8 +1136,14 @@ Condition *unit_find_failed_condition(Unit *u);
|
||||
|
||||
#define log_unit_struct_iovec_errno(unit, level, error, iovec, n_iovec) \
|
||||
({ \
|
||||
const Unit *_u = (unit); \
|
||||
const int _l = (level); \
|
||||
unit_log_level_test(unit, _l) ? \
|
||||
bool _do_log = unit_log_level_test(_u, _l); \
|
||||
const ExecContext *_c = _do_log && _u ? \
|
||||
unit_get_exec_context(_u) : NULL; \
|
||||
LOG_CONTEXT_PUSH_IOV(_c ? _c->log_extra_fields : NULL, \
|
||||
_c ? _c->n_log_extra_fields : 0); \
|
||||
_do_log ? \
|
||||
log_struct_iovec_errno(_l, error, iovec, n_iovec) : \
|
||||
-ERRNO_VALUE(error); \
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user