1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

tree-wide: add DEBUG_LOGGING macro that checks whether debug logging is on (#7645)

This makes things a bit easier to read I think, and also makes sure we
always use the _unlikely_ wrapper around it, which so far we used
sometimes and other times we didn't. Let's clean that up.
This commit is contained in:
Lennart Poettering 2017-12-15 11:09:00 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 42521cd1ed
commit f1d34068ef
13 changed files with 21 additions and 11 deletions

View File

@ -0,0 +1,8 @@
@@
@@
- _unlikely_(log_get_max_level() >= LOG_DEBUG)
+ DEBUG_LOGGING
@@
@@
- log_get_max_level() >= LOG_DEBUG
+ DEBUG_LOGGING

View File

@ -220,7 +220,7 @@ static int verify_unit(Unit *u, bool check_man) {
assert(u);
if (log_get_max_level() >= LOG_DEBUG)
if (DEBUG_LOGGING)
unit_dump(u, stdout, "\t");
log_unit_debug(u, "Creating %s/start job", u->id);

View File

@ -335,3 +335,5 @@ int log_syntax_internal(
"String is not UTF-8 clean, ignoring assignment: %s", strna(_p)); \
} \
})
#define DEBUG_LOGGING _unlikely_(log_get_max_level() >= LOG_DEBUG)

View File

@ -3418,7 +3418,7 @@ static int exec_child(
return log_oom();
}
if (_unlikely_(log_get_max_level() >= LOG_DEBUG)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *line;
line = exec_command_line(final_argv);

View File

@ -1887,7 +1887,7 @@ static void manager_invoke_notify_message(Manager *m, Unit *u, pid_t pid, const
if (UNIT_VTABLE(u)->notify_message)
UNIT_VTABLE(u)->notify_message(u, pid, tags, fds);
else if (_unlikely_(log_get_max_level() >= LOG_DEBUG)) {
else if (DEBUG_LOGGING) {
_cleanup_free_ char *x = NULL, *y = NULL;
x = cescape(buf);

View File

@ -3417,7 +3417,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds)
if (!service_notify_message_authorized(SERVICE(u), pid, tags, fds))
return;
if (log_get_max_level() >= LOG_DEBUG) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *cc = NULL;
cc = strv_join(tags, ", ");

View File

@ -1061,7 +1061,7 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto end;
if (_unlikely_(log_get_max_level() >= LOG_DEBUG)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *filter;
filter = journal_make_match_string(j);

View File

@ -248,7 +248,7 @@ int start_upload(Uploader *u,
easy_setopt(curl, CURLOPT_HTTPHEADER, u->header,
LOG_ERR, return -EXFULL);
if (_unlikely_(log_get_max_level() >= LOG_DEBUG))
if (DEBUG_LOGGING)
/* enable verbose for easier tracing */
easy_setopt(curl, CURLOPT_VERBOSE, 1L, LOG_WARNING, );

View File

@ -2257,7 +2257,7 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto finish;
if (_unlikely_(log_get_max_level() >= LOG_DEBUG)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *filter;
filter = journal_make_match_string(j);

View File

@ -476,7 +476,7 @@ static int dns_cache_put_positive(
if (r < 0)
return r;
if (log_get_max_level() >= LOG_DEBUG) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *t = NULL;
(void) in_addr_to_string(i->owner_family, &i->owner_address, &t);

View File

@ -1410,7 +1410,7 @@ void manager_dnssec_verdict(Manager *m, DnssecVerdict verdict, const DnsResource
assert(verdict >= 0);
assert(verdict < _DNSSEC_VERDICT_MAX);
if (log_get_max_level() >= LOG_DEBUG) {
if (DEBUG_LOGGING) {
char s[DNS_RESOURCE_KEY_STRING_MAX];
log_debug("Found verdict for lookup %s: %s",

View File

@ -1392,7 +1392,7 @@ int show_journal_by_unit(
if (r < 0)
return log_error_errno(r, "Failed to add unit matches: %m");
if (_unlikely_(log_get_max_level() >= LOG_DEBUG)) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *filter;
filter = journal_make_match_string(j);

View File

@ -954,7 +954,7 @@ int seccomp_restrict_namespaces(unsigned long retain) {
uint32_t arch;
int r;
if (log_get_max_level() >= LOG_DEBUG) {
if (DEBUG_LOGGING) {
_cleanup_free_ char *s = NULL;
(void) namespace_flag_to_string_many(retain, &s);