mirror of
https://github.com/systemd/systemd.git
synced 2025-08-02 04:22:27 +03:00
unit: Add LOG_CONTEXT_PUSH_UNIT()
A helper macro to push all unit related fields onto the log context. We also modify exec_spawn() to use it.
This commit is contained in:
@ -5474,6 +5474,8 @@ int exec_spawn(Unit *unit,
|
||||
assert(params);
|
||||
assert(params->fds || (params->n_socket_fds + params->n_storage_fds <= 0));
|
||||
|
||||
LOG_CONTEXT_PUSH_UNIT(unit);
|
||||
|
||||
if (context->std_input == EXEC_INPUT_SOCKET ||
|
||||
context->std_output == EXEC_OUTPUT_SOCKET ||
|
||||
context->std_error == EXEC_OUTPUT_SOCKET) {
|
||||
|
@ -1208,3 +1208,13 @@ typedef struct UnitForEachDependencyData {
|
||||
/* Note: this matches deps that have *any* of the atoms specified in match_atom set */
|
||||
#define UNIT_FOREACH_DEPENDENCY(other, u, match_atom) \
|
||||
_UNIT_FOREACH_DEPENDENCY(other, u, match_atom, UNIQ_T(data, UNIQ))
|
||||
|
||||
#define _LOG_CONTEXT_PUSH_UNIT(unit, u, c) \
|
||||
const Unit *u = (unit); \
|
||||
const ExecContext *c = unit_get_exec_context(u); \
|
||||
LOG_CONTEXT_PUSH_KEY_VALUE(u->manager->unit_log_field, u->id); \
|
||||
LOG_CONTEXT_PUSH_KEY_VALUE(u->manager->invocation_log_field, u->invocation_id_string); \
|
||||
LOG_CONTEXT_PUSH_IOV(c ? c->log_extra_fields : NULL, c ? c->n_log_extra_fields : 0)
|
||||
|
||||
#define LOG_CONTEXT_PUSH_UNIT(unit) \
|
||||
_LOG_CONTEXT_PUSH_UNIT(unit, UNIQ_T(u, UNIQ), UNIQ_T(c, UNIQ))
|
||||
|
Reference in New Issue
Block a user