core/execute: clean up log_exec_full_errno and friends
Also drop unused log_exec_struct_iovec().
This commit is contained in:
@@ -4795,7 +4795,6 @@ int exec_invoke(
|
|||||||
*exit_status = EXIT_EXEC;
|
*exit_status = EXIT_EXEC;
|
||||||
log_exec_struct_errno(context, params, LOG_NOTICE, r,
|
log_exec_struct_errno(context, params, LOG_NOTICE, r,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||||
LOG_EXEC_INVOCATION_ID(params),
|
|
||||||
LOG_EXEC_MESSAGE(params,
|
LOG_EXEC_MESSAGE(params,
|
||||||
"Unable to locate executable '%s': %m",
|
"Unable to locate executable '%s': %m",
|
||||||
command->path),
|
command->path),
|
||||||
|
|||||||
+38
-54
@@ -616,23 +616,26 @@ bool exec_needs_ipc_namespace(const ExecContext *context);
|
|||||||
#define LOG_EXEC_INVOCATION_ID_FIELD_FORMAT(ep) \
|
#define LOG_EXEC_INVOCATION_ID_FIELD_FORMAT(ep) \
|
||||||
((ep)->runtime_scope == RUNTIME_SCOPE_USER ? "USER_INVOCATION_ID=%s" : "INVOCATION_ID=%s")
|
((ep)->runtime_scope == RUNTIME_SCOPE_USER ? "USER_INVOCATION_ID=%s" : "INVOCATION_ID=%s")
|
||||||
|
|
||||||
#define log_exec_full_errno_zerook(ec, ep, level, error, ...) \
|
/* Like LOG_MESSAGE(), but with the unit name prefixed. */
|
||||||
({ \
|
#define LOG_EXEC_MESSAGE(ep, fmt, ...) LOG_MESSAGE("%s: " fmt, (ep)->unit_id, ##__VA_ARGS__)
|
||||||
const ExecContext *_c = (ec); \
|
#define LOG_EXEC_ID(ep) LOG_EXEC_ID_FIELD_FORMAT(ep), (ep)->unit_id
|
||||||
const ExecParameters *_p = (ep); \
|
#define LOG_EXEC_INVOCATION_ID(ep) LOG_EXEC_INVOCATION_ID_FIELD_FORMAT(ep), (ep)->invocation_id_string
|
||||||
const int _l = (level); \
|
|
||||||
bool _do_log = !(log_get_max_level() < LOG_PRI(_l) || \
|
#define log_exec_full_errno_zerook(ec, ep, level, error, ...) \
|
||||||
!(_c->log_level_max < 0 || \
|
({ \
|
||||||
_c->log_level_max >= LOG_PRI(_l))); \
|
const ExecContext *_c = (ec); \
|
||||||
LOG_CONTEXT_PUSH_IOV(_c->log_extra_fields, \
|
const ExecParameters *_p = (ep); \
|
||||||
_c->n_log_extra_fields); \
|
const int _l = (level); \
|
||||||
!_do_log ? -ERRNO_VALUE(error) : \
|
bool _do_log = _c->log_level_max >= 0 && \
|
||||||
log_object_internal(_l, error, PROJECT_FILE, \
|
_c->log_level_max < LOG_PRI(_l); \
|
||||||
__LINE__, __func__, \
|
LOG_CONTEXT_PUSH_IOV(_c->log_extra_fields, \
|
||||||
LOG_EXEC_ID_FIELD(_p), \
|
_c->n_log_extra_fields); \
|
||||||
_p->unit_id, \
|
!_do_log ? -ERRNO_VALUE(error) : \
|
||||||
LOG_EXEC_INVOCATION_ID_FIELD(_p), \
|
log_object_internal(_l, error, \
|
||||||
_p->invocation_id_string, ##__VA_ARGS__); \
|
PROJECT_FILE, __LINE__, __func__, \
|
||||||
|
LOG_EXEC_ID(_p), \
|
||||||
|
LOG_EXEC_INVOCATION_ID(_p), \
|
||||||
|
##__VA_ARGS__); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define log_exec_full_errno(ec, ep, level, error, ...) \
|
#define log_exec_full_errno(ec, ep, level, error, ...) \
|
||||||
@@ -656,48 +659,29 @@ bool exec_needs_ipc_namespace(const ExecContext *context);
|
|||||||
#define log_exec_warning_errno(ec, ep, error, ...) log_exec_full_errno(ec, ep, LOG_WARNING, error, __VA_ARGS__)
|
#define log_exec_warning_errno(ec, ep, error, ...) log_exec_full_errno(ec, ep, LOG_WARNING, error, __VA_ARGS__)
|
||||||
#define log_exec_error_errno(ec, ep, error, ...) log_exec_full_errno(ec, ep, LOG_ERR, error, __VA_ARGS__)
|
#define log_exec_error_errno(ec, ep, error, ...) log_exec_full_errno(ec, ep, LOG_ERR, error, __VA_ARGS__)
|
||||||
|
|
||||||
#define log_exec_struct_errno(ec, ep, level, error, ...) \
|
#define log_exec_struct_errno(ec, ep, level, error, ...) \
|
||||||
({ \
|
({ \
|
||||||
const ExecContext *_c = (ec); \
|
const ExecContext *_c = (ec); \
|
||||||
const ExecParameters *_p = (ep); \
|
const ExecParameters *_p = (ep); \
|
||||||
const int _l = (level); \
|
const int _l = (level); \
|
||||||
bool _do_log = !(_c->log_level_max < 0 || \
|
bool _do_log = _c->log_level_max >= 0 && \
|
||||||
_c->log_level_max >= LOG_PRI(_l)); \
|
_c->log_level_max < LOG_PRI(_l); \
|
||||||
LOG_CONTEXT_PUSH_IOV(_c->log_extra_fields, \
|
LOG_CONTEXT_PUSH_IOV(_c->log_extra_fields, \
|
||||||
_c->n_log_extra_fields); \
|
_c->n_log_extra_fields); \
|
||||||
_do_log ? \
|
!_do_log ? -ERRNO_VALUE(error) : \
|
||||||
log_struct_errno(_l, error, __VA_ARGS__, LOG_EXEC_ID_FIELD_FORMAT(_p), _p->unit_id) : \
|
log_struct_errno(_l, error, \
|
||||||
-ERRNO_VALUE(error); \
|
LOG_EXEC_ID(_p), \
|
||||||
|
LOG_EXEC_INVOCATION_ID(_p), \
|
||||||
|
__VA_ARGS__); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define log_exec_struct(ec, ep, level, ...) log_exec_struct_errno(ec, ep, level, 0, __VA_ARGS__)
|
#define log_exec_struct(ec, ep, level, ...) log_exec_struct_errno(ec, ep, level, 0, __VA_ARGS__)
|
||||||
|
|
||||||
#define log_exec_struct_iovec_errno(ec, ep, level, error, iovec, n_iovec) \
|
#define _LOG_CONTEXT_PUSH_EXEC(ec, ep, p, c) \
|
||||||
({ \
|
const ExecContext *c = (ec); \
|
||||||
const ExecContext *_c = (ec); \
|
const ExecParameters *p = (ep); \
|
||||||
const ExecParameters *_p = (ep); \
|
|
||||||
const int _l = (level); \
|
|
||||||
bool _do_log = !(_c->log_level_max < 0 || \
|
|
||||||
_c->log_level_max >= LOG_PRI(_l)); \
|
|
||||||
LOG_CONTEXT_PUSH_IOV(_c->log_extra_fields, \
|
|
||||||
_c->n_log_extra_fields); \
|
|
||||||
_do_log ? \
|
|
||||||
log_struct_iovec_errno(_l, error, iovec, n_iovec) : \
|
|
||||||
-ERRNO_VALUE(error); \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define log_exec_struct_iovec(ec, ep, level, iovec, n_iovec) log_exec_struct_iovec_errno(ec, ep, level, 0, iovec, n_iovec)
|
|
||||||
|
|
||||||
/* Like LOG_MESSAGE(), but with the unit name prefixed. */
|
|
||||||
#define LOG_EXEC_MESSAGE(ep, fmt, ...) LOG_MESSAGE("%s: " fmt, (ep)->unit_id, ##__VA_ARGS__)
|
|
||||||
#define LOG_EXEC_ID(ep) LOG_EXEC_ID_FIELD_FORMAT(ep), (ep)->unit_id
|
|
||||||
#define LOG_EXEC_INVOCATION_ID(ep) LOG_EXEC_INVOCATION_ID_FIELD_FORMAT(ep), (ep)->invocation_id_string
|
|
||||||
|
|
||||||
#define _LOG_CONTEXT_PUSH_EXEC(ec, ep, p, c) \
|
|
||||||
const ExecContext *c = (ec); \
|
|
||||||
const ExecParameters *p = (ep); \
|
|
||||||
LOG_CONTEXT_PUSH_KEY_VALUE(LOG_EXEC_ID_FIELD(p), p->unit_id); \
|
LOG_CONTEXT_PUSH_KEY_VALUE(LOG_EXEC_ID_FIELD(p), p->unit_id); \
|
||||||
LOG_CONTEXT_PUSH_KEY_VALUE(LOG_EXEC_INVOCATION_ID_FIELD(p), p->invocation_id_string); \
|
LOG_CONTEXT_PUSH_KEY_VALUE(LOG_EXEC_INVOCATION_ID_FIELD(p), p->invocation_id_string); \
|
||||||
LOG_CONTEXT_PUSH_IOV(c->log_extra_fields, c->n_log_extra_fields)
|
LOG_CONTEXT_PUSH_IOV(c->log_extra_fields, c->n_log_extra_fields)
|
||||||
|
|
||||||
#define LOG_CONTEXT_PUSH_EXEC(ec, ep) \
|
#define LOG_CONTEXT_PUSH_EXEC(ec, ep) \
|
||||||
|
|||||||
@@ -245,7 +245,6 @@ static int run(int argc, char *argv[]) {
|
|||||||
|
|
||||||
log_exec_struct_errno(&context, ¶ms, LOG_ERR, r,
|
log_exec_struct_errno(&context, ¶ms, LOG_ERR, r,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||||
LOG_EXEC_INVOCATION_ID(¶ms),
|
|
||||||
LOG_EXEC_MESSAGE(¶ms, "Failed at step %s spawning %s: %m",
|
LOG_EXEC_MESSAGE(¶ms, "Failed at step %s spawning %s: %m",
|
||||||
status, command.path),
|
status, command.path),
|
||||||
"EXECUTABLE=%s", command.path);
|
"EXECUTABLE=%s", command.path);
|
||||||
|
|||||||
Reference in New Issue
Block a user