mirror of
https://github.com/systemd/systemd
synced 2025-12-31 05:14:44 +01:00
Compare commits
14 Commits
172e8cf505
...
77c93e0a4e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77c93e0a4e | ||
|
|
54cf684f5f | ||
|
|
753803a66c | ||
|
|
c0c6809663 | ||
|
|
4c6eb1d77d | ||
|
|
5312fa8751 | ||
|
|
6d533e56f8 | ||
|
|
cd7ae1b44e | ||
|
|
bb146d238f | ||
|
|
7b376b29a3 | ||
|
|
9fdee66f2d | ||
|
|
3cc6b14a87 | ||
|
|
10d296c189 | ||
|
|
5df4f46f28 |
@ -80,7 +80,7 @@ elif [[ "$COMPILER" == gcc ]]; then
|
|||||||
AR="gcc-ar-$COMPILER_VERSION"
|
AR="gcc-ar-$COMPILER_VERSION"
|
||||||
# Latest gcc stack deb packages provided by
|
# Latest gcc stack deb packages provided by
|
||||||
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
|
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
|
||||||
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||||
PACKAGES+=(gcc-$COMPILER_VERSION)
|
PACKAGES+=(gcc-$COMPILER_VERSION)
|
||||||
else
|
else
|
||||||
fatal "Unknown compiler: $COMPILER"
|
fatal "Unknown compiler: $COMPILER"
|
||||||
@ -99,6 +99,8 @@ pip3 install --user -U meson ninja
|
|||||||
export PATH="$HOME/.local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
|
||||||
$CC --version
|
$CC --version
|
||||||
|
meson --version
|
||||||
|
ninja --version
|
||||||
|
|
||||||
for args in "${ARGS[@]}"; do
|
for args in "${ARGS[@]}"; do
|
||||||
SECONDS=0
|
SECONDS=0
|
||||||
@ -108,9 +110,8 @@ for args in "${ARGS[@]}"; do
|
|||||||
fatal "meson failed with $args"
|
fatal "meson failed with $args"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ninja --version
|
if ! meson compile -C build; then
|
||||||
if ! ninja -C build; then
|
fatal "'meson compile' failed with $args"
|
||||||
fatal "ninja failed with $args"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git clean -dxf
|
git clean -dxf
|
||||||
2
.github/workflows/build_test.yml
vendored
2
.github/workflows/build_test.yml
vendored
@ -26,4 +26,4 @@ jobs:
|
|||||||
- name: Repository checkout
|
- name: Repository checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
- name: Build check (${{ env.COMPILER }}-${{ env.COMPILER_VERSION }})
|
- name: Build check (${{ env.COMPILER }}-${{ env.COMPILER_VERSION }})
|
||||||
run: sudo -E .github/workflows/ubuntu-build-check.sh
|
run: sudo -E .github/workflows/build_test.sh
|
||||||
|
|||||||
2
.github/workflows/coverity.yml
vendored
2
.github/workflows/coverity.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
|||||||
run: tools/get-coverity.sh
|
run: tools/get-coverity.sh
|
||||||
# Reuse the setup phase of the unit test script to avoid code duplication
|
# Reuse the setup phase of the unit test script to avoid code duplication
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
run: sudo -E .github/workflows/ubuntu-unit-tests.sh SETUP
|
run: sudo -E .github/workflows/unit_tests.sh SETUP
|
||||||
# Preconfigure with meson to prevent Coverity from capturing meson metadata
|
# Preconfigure with meson to prevent Coverity from capturing meson metadata
|
||||||
- name: Preconfigure the build directory
|
- name: Preconfigure the build directory
|
||||||
run: meson cov-build -Dman=false
|
run: meson cov-build -Dman=false
|
||||||
|
|||||||
4
.github/workflows/unit_tests.yml
vendored
4
.github/workflows/unit_tests.yml
vendored
@ -18,6 +18,6 @@ jobs:
|
|||||||
- name: Repository checkout
|
- name: Repository checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
run: sudo -E .github/workflows/ubuntu-unit-tests.sh SETUP
|
run: sudo -E .github/workflows/unit_tests.sh SETUP
|
||||||
- name: Build & test (${{ matrix.run_phase }})
|
- name: Build & test (${{ matrix.run_phase }})
|
||||||
run: sudo -E .github/workflows/ubuntu-unit-tests.sh RUN_${{ matrix.run_phase }}
|
run: sudo -E .github/workflows/unit_tests.sh RUN_${{ matrix.run_phase }}
|
||||||
|
|||||||
@ -3161,7 +3161,6 @@ public_programs += executable(
|
|||||||
public_programs += executable(
|
public_programs += executable(
|
||||||
'udevadm',
|
'udevadm',
|
||||||
udevadm_sources,
|
udevadm_sources,
|
||||||
c_args : '-DLOG_REALM=LOG_REALM_UDEV',
|
|
||||||
include_directories : includes,
|
include_directories : includes,
|
||||||
link_with : [libudevd_core],
|
link_with : [libudevd_core],
|
||||||
dependencies : [versiondep,
|
dependencies : [versiondep,
|
||||||
|
|||||||
@ -40,8 +40,7 @@
|
|||||||
#define SNDBUF_SIZE (8*1024*1024)
|
#define SNDBUF_SIZE (8*1024*1024)
|
||||||
|
|
||||||
static LogTarget log_target = LOG_TARGET_CONSOLE;
|
static LogTarget log_target = LOG_TARGET_CONSOLE;
|
||||||
static int log_max_level[] = {LOG_INFO, LOG_INFO};
|
static int log_max_level = LOG_INFO;
|
||||||
assert_cc(ELEMENTSOF(log_max_level) == _LOG_REALM_MAX);
|
|
||||||
static int log_facility = LOG_DAEMON;
|
static int log_facility = LOG_DAEMON;
|
||||||
|
|
||||||
static int console_fd = STDERR_FILENO;
|
static int console_fd = STDERR_FILENO;
|
||||||
@ -352,11 +351,10 @@ void log_forget_fds(void) {
|
|||||||
console_fd = kmsg_fd = syslog_fd = journal_fd = -1;
|
console_fd = kmsg_fd = syslog_fd = journal_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_set_max_level_realm(LogRealm realm, int level) {
|
void log_set_max_level(int level) {
|
||||||
assert((level & LOG_PRIMASK) == level);
|
assert((level & LOG_PRIMASK) == level);
|
||||||
assert(realm < ELEMENTSOF(log_max_level));
|
|
||||||
|
|
||||||
log_max_level[realm] = level;
|
log_max_level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_set_facility(int facility) {
|
void log_set_facility(int facility) {
|
||||||
@ -405,7 +403,7 @@ static int write_to_console(
|
|||||||
const char *lon = "", *loff = "";
|
const char *lon = "", *loff = "";
|
||||||
if (log_get_show_color()) {
|
if (log_get_show_color()) {
|
||||||
lon = ansi_highlight_yellow4();
|
lon = ansi_highlight_yellow4();
|
||||||
loff = ANSI_NORMAL;
|
loff = ansi_normal();
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) snprintf(location, sizeof location, "%s%s:%i%s: ", lon, file, line, loff);
|
(void) snprintf(location, sizeof location, "%s%s:%i%s: ", lon, file, line, loff);
|
||||||
@ -716,18 +714,17 @@ int log_dump_internal(
|
|||||||
const char *func,
|
const char *func,
|
||||||
char *buffer) {
|
char *buffer) {
|
||||||
|
|
||||||
LogRealm realm = LOG_REALM_REMOVE_LEVEL(level);
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
|
|
||||||
/* This modifies the buffer... */
|
/* This modifies the buffer... */
|
||||||
|
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[realm]))
|
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||||
return -ERRNO_VALUE(error);
|
return -ERRNO_VALUE(error);
|
||||||
|
|
||||||
return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
|
return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_internalv_realm(
|
int log_internalv(
|
||||||
int level,
|
int level,
|
||||||
int error,
|
int error,
|
||||||
const char *file,
|
const char *file,
|
||||||
@ -736,11 +733,10 @@ int log_internalv_realm(
|
|||||||
const char *format,
|
const char *format,
|
||||||
va_list ap) {
|
va_list ap) {
|
||||||
|
|
||||||
LogRealm realm = LOG_REALM_REMOVE_LEVEL(level);
|
|
||||||
char buffer[LINE_MAX];
|
char buffer[LINE_MAX];
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
|
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[realm]))
|
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||||
return -ERRNO_VALUE(error);
|
return -ERRNO_VALUE(error);
|
||||||
|
|
||||||
/* Make sure that %m maps to the specified error (or "Success"). */
|
/* Make sure that %m maps to the specified error (or "Success"). */
|
||||||
@ -751,7 +747,7 @@ int log_internalv_realm(
|
|||||||
return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
|
return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_internal_realm(
|
int log_internal(
|
||||||
int level,
|
int level,
|
||||||
int error,
|
int error,
|
||||||
const char *file,
|
const char *file,
|
||||||
@ -763,7 +759,7 @@ int log_internal_realm(
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
r = log_internalv_realm(level, error, file, line, func, format, ap);
|
r = log_internalv(level, error, file, line, func, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@ -785,7 +781,7 @@ int log_object_internalv(
|
|||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
char *buffer, *b;
|
char *buffer, *b;
|
||||||
|
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[LOG_REALM_SYSTEMD]))
|
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||||
return -ERRNO_VALUE(error);
|
return -ERRNO_VALUE(error);
|
||||||
|
|
||||||
/* Make sure that %m maps to the specified error (or "Success"). */
|
/* Make sure that %m maps to the specified error (or "Success"). */
|
||||||
@ -838,9 +834,8 @@ static void log_assert(
|
|||||||
const char *format) {
|
const char *format) {
|
||||||
|
|
||||||
static char buffer[LINE_MAX];
|
static char buffer[LINE_MAX];
|
||||||
LogRealm realm = LOG_REALM_REMOVE_LEVEL(level);
|
|
||||||
|
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[realm]))
|
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DISABLE_WARNING_FORMAT_NONLITERAL;
|
DISABLE_WARNING_FORMAT_NONLITERAL;
|
||||||
@ -852,41 +847,38 @@ static void log_assert(
|
|||||||
log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer);
|
log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_noreturn_ void log_assert_failed_realm(
|
_noreturn_ void log_assert_failed(
|
||||||
LogRealm realm,
|
|
||||||
const char *text,
|
const char *text,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
const char *func) {
|
const char *func) {
|
||||||
log_assert(LOG_REALM_PLUS_LEVEL(realm, LOG_CRIT), text, file, line, func,
|
log_assert(LOG_CRIT, text, file, line, func,
|
||||||
"Assertion '%s' failed at %s:%u, function %s(). Aborting.");
|
"Assertion '%s' failed at %s:%u, function %s(). Aborting.");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
_noreturn_ void log_assert_failed_unreachable_realm(
|
_noreturn_ void log_assert_failed_unreachable(
|
||||||
LogRealm realm,
|
|
||||||
const char *text,
|
const char *text,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
const char *func) {
|
const char *func) {
|
||||||
log_assert(LOG_REALM_PLUS_LEVEL(realm, LOG_CRIT), text, file, line, func,
|
log_assert(LOG_CRIT, text, file, line, func,
|
||||||
"Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
|
"Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_assert_failed_return_realm(
|
void log_assert_failed_return(
|
||||||
LogRealm realm,
|
|
||||||
const char *text,
|
const char *text,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
const char *func) {
|
const char *func) {
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
log_assert(LOG_REALM_PLUS_LEVEL(realm, LOG_DEBUG), text, file, line, func,
|
log_assert(LOG_DEBUG, text, file, line, func,
|
||||||
"Assertion '%s' failed at %s:%u, function %s(). Ignoring.");
|
"Assertion '%s' failed at %s:%u, function %s(). Ignoring.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_oom_internal(int level, const char *file, int line, const char *func) {
|
int log_oom_internal(int level, const char *file, int line, const char *func) {
|
||||||
return log_internal_realm(level, ENOMEM, file, line, func, "Out of memory.");
|
return log_internal(level, ENOMEM, file, line, func, "Out of memory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_format_iovec(
|
int log_format_iovec(
|
||||||
@ -941,13 +933,12 @@ int log_struct_internal(
|
|||||||
const char *func,
|
const char *func,
|
||||||
const char *format, ...) {
|
const char *format, ...) {
|
||||||
|
|
||||||
LogRealm realm = LOG_REALM_REMOVE_LEVEL(level);
|
|
||||||
char buf[LINE_MAX];
|
char buf[LINE_MAX];
|
||||||
bool found = false;
|
bool found = false;
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[realm]) ||
|
if (_likely_(LOG_PRI(level) > log_max_level) ||
|
||||||
log_target == LOG_TARGET_NULL)
|
log_target == LOG_TARGET_NULL)
|
||||||
return -ERRNO_VALUE(error);
|
return -ERRNO_VALUE(error);
|
||||||
|
|
||||||
@ -1041,12 +1032,11 @@ int log_struct_iovec_internal(
|
|||||||
const struct iovec input_iovec[],
|
const struct iovec input_iovec[],
|
||||||
size_t n_input_iovec) {
|
size_t n_input_iovec) {
|
||||||
|
|
||||||
LogRealm realm = LOG_REALM_REMOVE_LEVEL(level);
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
size_t i;
|
size_t i;
|
||||||
char *m;
|
char *m;
|
||||||
|
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[realm]) ||
|
if (_likely_(LOG_PRI(level) > log_max_level) ||
|
||||||
log_target == LOG_TARGET_NULL)
|
log_target == LOG_TARGET_NULL)
|
||||||
return -ERRNO_VALUE(error);
|
return -ERRNO_VALUE(error);
|
||||||
|
|
||||||
@ -1101,14 +1091,14 @@ int log_set_target_from_string(const char *e) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_set_max_level_from_string_realm(LogRealm realm, const char *e) {
|
int log_set_max_level_from_string(const char *e) {
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
t = log_level_from_string(e);
|
t = log_level_from_string(e);
|
||||||
if (t < 0)
|
if (t < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
log_set_max_level_realm(realm, t);
|
log_set_max_level(t);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1167,17 +1157,17 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_parse_environment_realm(LogRealm realm) {
|
void log_parse_environment(void) {
|
||||||
if (getpid_cached() == 1 || get_ctty_devnr(0, NULL) < 0)
|
if (getpid_cached() == 1 || get_ctty_devnr(0, NULL) < 0)
|
||||||
/* Only try to read the command line in daemons. We assume that anything that has a
|
/* Only try to read the command line in daemons. We assume that anything that has a
|
||||||
* controlling tty is user stuff. For PID1 we do a special check in case it hasn't
|
* controlling tty is user stuff. For PID1 we do a special check in case it hasn't
|
||||||
* closed the console yet. */
|
* closed the console yet. */
|
||||||
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
|
(void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX);
|
||||||
|
|
||||||
log_parse_environment_cli_realm(realm);
|
log_parse_environment_cli();
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_parse_environment_cli_realm(LogRealm realm) {
|
void log_parse_environment_cli(void) {
|
||||||
/* Do not call from library code. */
|
/* Do not call from library code. */
|
||||||
|
|
||||||
const char *e;
|
const char *e;
|
||||||
@ -1187,7 +1177,7 @@ void log_parse_environment_cli_realm(LogRealm realm) {
|
|||||||
log_warning("Failed to parse log target '%s'. Ignoring.", e);
|
log_warning("Failed to parse log target '%s'. Ignoring.", e);
|
||||||
|
|
||||||
e = getenv("SYSTEMD_LOG_LEVEL");
|
e = getenv("SYSTEMD_LOG_LEVEL");
|
||||||
if (e && log_set_max_level_from_string_realm(realm, e) < 0)
|
if (e && log_set_max_level_from_string(e) < 0)
|
||||||
log_warning("Failed to parse log level '%s'. Ignoring.", e);
|
log_warning("Failed to parse log level '%s'. Ignoring.", e);
|
||||||
|
|
||||||
e = getenv("SYSTEMD_LOG_COLOR");
|
e = getenv("SYSTEMD_LOG_COLOR");
|
||||||
@ -1211,8 +1201,8 @@ LogTarget log_get_target(void) {
|
|||||||
return log_target;
|
return log_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_get_max_level_realm(LogRealm realm) {
|
int log_get_max_level(void) {
|
||||||
return log_max_level[realm];
|
return log_max_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_show_color(bool b) {
|
void log_show_color(bool b) {
|
||||||
@ -1347,7 +1337,7 @@ int log_syntax_internal(
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
const char *unit_fmt = NULL;
|
const char *unit_fmt = NULL;
|
||||||
|
|
||||||
if (_likely_(LOG_PRI(level) > log_max_level[LOG_REALM_SYSTEMD]) ||
|
if (_likely_(LOG_PRI(level) > log_max_level) ||
|
||||||
log_target == LOG_TARGET_NULL)
|
log_target == LOG_TARGET_NULL)
|
||||||
return -ERRNO_VALUE(error);
|
return -ERRNO_VALUE(error);
|
||||||
|
|
||||||
@ -1363,7 +1353,7 @@ int log_syntax_internal(
|
|||||||
if (config_file) {
|
if (config_file) {
|
||||||
if (config_line > 0)
|
if (config_line > 0)
|
||||||
return log_struct_internal(
|
return log_struct_internal(
|
||||||
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
|
level,
|
||||||
error,
|
error,
|
||||||
file, line, func,
|
file, line, func,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
||||||
@ -1374,7 +1364,7 @@ int log_syntax_internal(
|
|||||||
NULL);
|
NULL);
|
||||||
else
|
else
|
||||||
return log_struct_internal(
|
return log_struct_internal(
|
||||||
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
|
level,
|
||||||
error,
|
error,
|
||||||
file, line, func,
|
file, line, func,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
||||||
@ -1384,7 +1374,7 @@ int log_syntax_internal(
|
|||||||
NULL);
|
NULL);
|
||||||
} else if (unit)
|
} else if (unit)
|
||||||
return log_struct_internal(
|
return log_struct_internal(
|
||||||
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
|
level,
|
||||||
error,
|
error,
|
||||||
file, line, func,
|
file, line, func,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
||||||
@ -1393,7 +1383,7 @@ int log_syntax_internal(
|
|||||||
NULL);
|
NULL);
|
||||||
else
|
else
|
||||||
return log_struct_internal(
|
return log_struct_internal(
|
||||||
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
|
level,
|
||||||
error,
|
error,
|
||||||
file, line, func,
|
file, line, func,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
||||||
|
|||||||
105
src/basic/log.h
105
src/basic/log.h
@ -12,16 +12,6 @@
|
|||||||
struct iovec;
|
struct iovec;
|
||||||
struct signalfd_siginfo;
|
struct signalfd_siginfo;
|
||||||
|
|
||||||
typedef enum LogRealm {
|
|
||||||
LOG_REALM_SYSTEMD,
|
|
||||||
LOG_REALM_UDEV,
|
|
||||||
_LOG_REALM_MAX,
|
|
||||||
} LogRealm;
|
|
||||||
|
|
||||||
#ifndef LOG_REALM
|
|
||||||
# define LOG_REALM LOG_REALM_SYSTEMD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum LogTarget{
|
typedef enum LogTarget{
|
||||||
LOG_TARGET_CONSOLE,
|
LOG_TARGET_CONSOLE,
|
||||||
LOG_TARGET_CONSOLE_PREFIXED,
|
LOG_TARGET_CONSOLE_PREFIXED,
|
||||||
@ -37,31 +27,22 @@ typedef enum LogTarget{
|
|||||||
} LogTarget;
|
} LogTarget;
|
||||||
|
|
||||||
/* Note to readers: << and >> have lower precedence than & and | */
|
/* Note to readers: << and >> have lower precedence than & and | */
|
||||||
#define LOG_REALM_PLUS_LEVEL(realm, level) ((realm) << 10 | (level))
|
|
||||||
#define LOG_REALM_REMOVE_LEVEL(realm_level) ((realm_level) >> 10)
|
|
||||||
#define SYNTHETIC_ERRNO(num) (1 << 30 | (num))
|
#define SYNTHETIC_ERRNO(num) (1 << 30 | (num))
|
||||||
#define IS_SYNTHETIC_ERRNO(val) ((val) >> 30 & 1)
|
#define IS_SYNTHETIC_ERRNO(val) ((val) >> 30 & 1)
|
||||||
#define ERRNO_VALUE(val) (abs(val) & 255)
|
#define ERRNO_VALUE(val) (abs(val) & 255)
|
||||||
|
|
||||||
|
const char *log_target_to_string(LogTarget target) _const_;
|
||||||
|
LogTarget log_target_from_string(const char *s) _pure_;
|
||||||
void log_set_target(LogTarget target);
|
void log_set_target(LogTarget target);
|
||||||
|
int log_set_target_from_string(const char *e);
|
||||||
|
LogTarget log_get_target(void) _pure_;
|
||||||
|
|
||||||
void log_set_max_level_realm(LogRealm realm, int level);
|
void log_set_max_level(int level);
|
||||||
|
int log_set_max_level_from_string(const char *e);
|
||||||
#define log_set_max_level(level) \
|
int log_get_max_level(void) _pure_;
|
||||||
log_set_max_level_realm(LOG_REALM, (level))
|
|
||||||
|
|
||||||
static inline void log_set_max_level_all_realms(int level) {
|
|
||||||
for (LogRealm realm = 0; realm < _LOG_REALM_MAX; realm++)
|
|
||||||
log_set_max_level_realm(realm, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_set_facility(int facility);
|
void log_set_facility(int facility);
|
||||||
|
|
||||||
int log_set_target_from_string(const char *e);
|
|
||||||
int log_set_max_level_from_string_realm(LogRealm realm, const char *e);
|
|
||||||
#define log_set_max_level_from_string(e) \
|
|
||||||
log_set_max_level_from_string_realm(LOG_REALM, (e))
|
|
||||||
|
|
||||||
void log_show_color(bool b);
|
void log_show_color(bool b);
|
||||||
bool log_get_show_color(void) _pure_;
|
bool log_get_show_color(void) _pure_;
|
||||||
void log_show_location(bool b);
|
void log_show_location(bool b);
|
||||||
@ -76,15 +57,9 @@ int log_show_location_from_string(const char *e);
|
|||||||
int log_show_time_from_string(const char *e);
|
int log_show_time_from_string(const char *e);
|
||||||
int log_show_tid_from_string(const char *e);
|
int log_show_tid_from_string(const char *e);
|
||||||
|
|
||||||
LogTarget log_get_target(void) _pure_;
|
|
||||||
int log_get_max_level_realm(LogRealm realm) _pure_;
|
|
||||||
#define log_get_max_level() \
|
|
||||||
log_get_max_level_realm(LOG_REALM)
|
|
||||||
|
|
||||||
/* Functions below that open and close logs or configure logging based on the
|
/* Functions below that open and close logs or configure logging based on the
|
||||||
* environment should not be called from library code — this is always a job
|
* environment should not be called from library code — this is always a job
|
||||||
* for the application itself.
|
* for the application itself. */
|
||||||
*/
|
|
||||||
|
|
||||||
assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1);
|
assert_cc(STRLEN(__FILE__) > STRLEN(RELATIVE_SOURCE_PATH) + 1);
|
||||||
#define PROJECT_FILE (&__FILE__[STRLEN(RELATIVE_SOURCE_PATH) + 1])
|
#define PROJECT_FILE (&__FILE__[STRLEN(RELATIVE_SOURCE_PATH) + 1])
|
||||||
@ -93,12 +68,8 @@ int log_open(void);
|
|||||||
void log_close(void);
|
void log_close(void);
|
||||||
void log_forget_fds(void);
|
void log_forget_fds(void);
|
||||||
|
|
||||||
void log_parse_environment_realm(LogRealm realm);
|
void log_parse_environment(void);
|
||||||
void log_parse_environment_cli_realm(LogRealm realm);
|
void log_parse_environment_cli(void);
|
||||||
#define log_parse_environment() \
|
|
||||||
log_parse_environment_realm(LOG_REALM)
|
|
||||||
#define log_parse_environment_cli() \
|
|
||||||
log_parse_environment_cli_realm(LOG_REALM)
|
|
||||||
|
|
||||||
int log_dispatch_internal(
|
int log_dispatch_internal(
|
||||||
int level,
|
int level,
|
||||||
@ -112,17 +83,15 @@ int log_dispatch_internal(
|
|||||||
const char *extra_field,
|
const char *extra_field,
|
||||||
char *buffer);
|
char *buffer);
|
||||||
|
|
||||||
int log_internal_realm(
|
int log_internal(
|
||||||
int level,
|
int level,
|
||||||
int error,
|
int error,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
const char *func,
|
const char *func,
|
||||||
const char *format, ...) _printf_(6,7);
|
const char *format, ...) _printf_(6,7);
|
||||||
#define log_internal(level, ...) \
|
|
||||||
log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
|
|
||||||
|
|
||||||
int log_internalv_realm(
|
int log_internalv(
|
||||||
int level,
|
int level,
|
||||||
int error,
|
int error,
|
||||||
const char *file,
|
const char *file,
|
||||||
@ -130,10 +99,7 @@ int log_internalv_realm(
|
|||||||
const char *func,
|
const char *func,
|
||||||
const char *format,
|
const char *format,
|
||||||
va_list ap) _printf_(6,0);
|
va_list ap) _printf_(6,0);
|
||||||
#define log_internalv(level, ...) \
|
|
||||||
log_internalv_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
|
|
||||||
|
|
||||||
/* Realm is fixed to LOG_REALM_SYSTEMD for those */
|
|
||||||
int log_object_internalv(
|
int log_object_internalv(
|
||||||
int level,
|
int level,
|
||||||
int error,
|
int error,
|
||||||
@ -201,49 +167,36 @@ int log_dump_internal(
|
|||||||
char *buffer);
|
char *buffer);
|
||||||
|
|
||||||
/* Logging for various assertions */
|
/* Logging for various assertions */
|
||||||
_noreturn_ void log_assert_failed_realm(
|
_noreturn_ void log_assert_failed(
|
||||||
LogRealm realm,
|
|
||||||
const char *text,
|
const char *text,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
const char *func);
|
const char *func);
|
||||||
#define log_assert_failed(text, ...) \
|
|
||||||
log_assert_failed_realm(LOG_REALM, (text), __VA_ARGS__)
|
|
||||||
|
|
||||||
_noreturn_ void log_assert_failed_unreachable_realm(
|
_noreturn_ void log_assert_failed_unreachable(
|
||||||
LogRealm realm,
|
|
||||||
const char *text,
|
const char *text,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
const char *func);
|
const char *func);
|
||||||
#define log_assert_failed_unreachable(text, ...) \
|
|
||||||
log_assert_failed_unreachable_realm(LOG_REALM, (text), __VA_ARGS__)
|
|
||||||
|
|
||||||
void log_assert_failed_return_realm(
|
void log_assert_failed_return(
|
||||||
LogRealm realm,
|
|
||||||
const char *text,
|
const char *text,
|
||||||
const char *file,
|
const char *file,
|
||||||
int line,
|
int line,
|
||||||
const char *func);
|
const char *func);
|
||||||
#define log_assert_failed_return(text, ...) \
|
|
||||||
log_assert_failed_return_realm(LOG_REALM, (text), __VA_ARGS__)
|
|
||||||
|
|
||||||
#define log_dispatch(level, error, buffer) \
|
#define log_dispatch(level, error, buffer) \
|
||||||
log_dispatch_internal(level, error, PROJECT_FILE, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer)
|
log_dispatch_internal(level, error, PROJECT_FILE, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer)
|
||||||
|
|
||||||
/* Logging with level */
|
/* Logging with level */
|
||||||
#define log_full_errno_realm(realm, level, error, ...) \
|
#define log_full_errno(level, error, ...) \
|
||||||
({ \
|
({ \
|
||||||
int _level = (level), _e = (error), _realm = (realm); \
|
int _level = (level), _e = (error); \
|
||||||
(log_get_max_level_realm(_realm) >= LOG_PRI(_level)) \
|
(log_get_max_level() >= LOG_PRI(_level)) \
|
||||||
? log_internal_realm(LOG_REALM_PLUS_LEVEL(_realm, _level), _e, \
|
? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
|
||||||
PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
|
|
||||||
: -ERRNO_VALUE(_e); \
|
: -ERRNO_VALUE(_e); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define log_full_errno(level, error, ...) \
|
|
||||||
log_full_errno_realm(LOG_REALM, (level), (error), __VA_ARGS__)
|
|
||||||
|
|
||||||
#define log_full(level, ...) (void) log_full_errno((level), 0, __VA_ARGS__)
|
#define log_full(level, ...) (void) log_full_errno((level), 0, __VA_ARGS__)
|
||||||
|
|
||||||
int log_emergency_level(void);
|
int log_emergency_level(void);
|
||||||
@ -271,29 +224,23 @@ int log_emergency_level(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Structured logging */
|
/* Structured logging */
|
||||||
#define log_struct_errno(level, error, ...) \
|
#define log_struct_errno(level, error, ...) \
|
||||||
log_struct_internal(LOG_REALM_PLUS_LEVEL(LOG_REALM, level), \
|
log_struct_internal(level, error, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__, NULL)
|
||||||
error, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__, NULL)
|
|
||||||
#define log_struct(level, ...) log_struct_errno(level, 0, __VA_ARGS__)
|
#define log_struct(level, ...) log_struct_errno(level, 0, __VA_ARGS__)
|
||||||
|
|
||||||
#define log_struct_iovec_errno(level, error, iovec, n_iovec) \
|
#define log_struct_iovec_errno(level, error, iovec, n_iovec) \
|
||||||
log_struct_iovec_internal(LOG_REALM_PLUS_LEVEL(LOG_REALM, level), \
|
log_struct_iovec_internal(level, error, PROJECT_FILE, __LINE__, __func__, iovec, n_iovec)
|
||||||
error, PROJECT_FILE, __LINE__, __func__, iovec, n_iovec)
|
|
||||||
#define log_struct_iovec(level, iovec, n_iovec) log_struct_iovec_errno(level, 0, iovec, n_iovec)
|
#define log_struct_iovec(level, iovec, n_iovec) log_struct_iovec_errno(level, 0, iovec, n_iovec)
|
||||||
|
|
||||||
/* This modifies the buffer passed! */
|
/* This modifies the buffer passed! */
|
||||||
#define log_dump(level, buffer) \
|
#define log_dump(level, buffer) \
|
||||||
log_dump_internal(LOG_REALM_PLUS_LEVEL(LOG_REALM, level), \
|
log_dump_internal(level, 0, PROJECT_FILE, __LINE__, __func__, buffer)
|
||||||
0, PROJECT_FILE, __LINE__, __func__, buffer)
|
|
||||||
|
|
||||||
#define log_oom() log_oom_internal(LOG_REALM_PLUS_LEVEL(LOG_REALM, LOG_ERR), PROJECT_FILE, __LINE__, __func__)
|
#define log_oom() log_oom_internal(LOG_ERR, PROJECT_FILE, __LINE__, __func__)
|
||||||
#define log_oom_debug() log_oom_internal(LOG_REALM_PLUS_LEVEL(LOG_REALM, LOG_DEBUG), PROJECT_FILE, __LINE__, __func__)
|
#define log_oom_debug() log_oom_internal(LOG_DEBUG, PROJECT_FILE, __LINE__, __func__)
|
||||||
|
|
||||||
bool log_on_console(void) _pure_;
|
bool log_on_console(void) _pure_;
|
||||||
|
|
||||||
const char *log_target_to_string(LogTarget target) _const_;
|
|
||||||
LogTarget log_target_from_string(const char *s) _pure_;
|
|
||||||
|
|
||||||
/* Helper to prepare various field for structured logging */
|
/* Helper to prepare various field for structured logging */
|
||||||
#define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__
|
#define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ static struct selabel_handle *label_hnd = NULL;
|
|||||||
int _e = (error); \
|
int _e = (error); \
|
||||||
\
|
\
|
||||||
int _r = (log_get_max_level() >= LOG_PRI(_level)) \
|
int _r = (log_get_max_level() >= LOG_PRI(_level)) \
|
||||||
? log_internal_realm(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
|
? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
|
||||||
: -ERRNO_VALUE(_e); \
|
: -ERRNO_VALUE(_e); \
|
||||||
_enforcing ? _r : 0; \
|
_enforcing ? _r : 0; \
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1375,23 +1375,23 @@ void get_log_colors(int priority, const char **on, const char **off, const char
|
|||||||
if (on)
|
if (on)
|
||||||
*on = ansi_highlight_red();
|
*on = ansi_highlight_red();
|
||||||
if (off)
|
if (off)
|
||||||
*off = ANSI_NORMAL;
|
*off = ansi_normal();
|
||||||
if (highlight)
|
if (highlight)
|
||||||
*highlight = ANSI_HIGHLIGHT;
|
*highlight = ansi_highlight();
|
||||||
|
|
||||||
} else if (priority <= LOG_WARNING) {
|
} else if (priority <= LOG_WARNING) {
|
||||||
if (on)
|
if (on)
|
||||||
*on = ansi_highlight_yellow();
|
*on = ansi_highlight_yellow();
|
||||||
if (off)
|
if (off)
|
||||||
*off = ANSI_NORMAL;
|
*off = ansi_normal();
|
||||||
if (highlight)
|
if (highlight)
|
||||||
*highlight = ANSI_HIGHLIGHT;
|
*highlight = ansi_highlight();
|
||||||
|
|
||||||
} else if (priority <= LOG_NOTICE) {
|
} else if (priority <= LOG_NOTICE) {
|
||||||
if (on)
|
if (on)
|
||||||
*on = ANSI_HIGHLIGHT;
|
*on = ansi_highlight();
|
||||||
if (off)
|
if (off)
|
||||||
*off = ANSI_NORMAL;
|
*off = ansi_normal();
|
||||||
if (highlight)
|
if (highlight)
|
||||||
*highlight = ansi_highlight_red();
|
*highlight = ansi_highlight_red();
|
||||||
|
|
||||||
@ -1399,7 +1399,7 @@ void get_log_colors(int priority, const char **on, const char **off, const char
|
|||||||
if (on)
|
if (on)
|
||||||
*on = ansi_grey();
|
*on = ansi_grey();
|
||||||
if (off)
|
if (off)
|
||||||
*off = ANSI_NORMAL;
|
*off = ansi_normal();
|
||||||
if (highlight)
|
if (highlight)
|
||||||
*highlight = ansi_highlight_red();
|
*highlight = ansi_highlight_red();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1080,14 +1080,12 @@ static int run(int argc, char *argv[]) {
|
|||||||
case '?':
|
case '?':
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
||||||
#define ON ANSI_HIGHLIGHT
|
|
||||||
#define OFF ANSI_NORMAL
|
|
||||||
|
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"\t<" ON "p" OFF "> By path; <" ON "t" OFF "> By tasks/procs; <" ON "c" OFF "> By CPU; <" ON "m" OFF "> By memory; <" ON "i" OFF "> By I/O\n"
|
"\t<%1$sp%2$s> By path; <%1$st%2$s> By tasks/procs; <%1$sc%2$s> By CPU; <%1$sm%2$s> By memory; <%1$si%2$s> By I/O\n"
|
||||||
"\t<" ON "+" OFF "> Inc. delay; <" ON "-" OFF "> Dec. delay; <" ON "%%" OFF "> Toggle time; <" ON "SPACE" OFF "> Refresh\n"
|
"\t<%1$s+%2$s> Inc. delay; <%1$s-%2$s> Dec. delay; <%1$s%%%2$s> Toggle time; <%1$sSPACE%2$s> Refresh\n"
|
||||||
"\t<" ON "P" OFF "> Toggle count userspace processes; <" ON "k" OFF "> Toggle count all processes\n"
|
"\t<%1$sP%2$s> Toggle count userspace processes; <%1$sk%2$s> Toggle count all processes\n"
|
||||||
"\t<" ON "r" OFF "> Count processes recursively; <" ON "q" OFF "> Quit");
|
"\t<%1$sr%2$s> Count processes recursively; <%1$sq%2$s> Quit",
|
||||||
|
ansi_highlight(), ansi_normal());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -3891,7 +3891,7 @@ int json_log_internal(
|
|||||||
|
|
||||||
if (source && source_line > 0 && source_column > 0)
|
if (source && source_line > 0 && source_column > 0)
|
||||||
return log_struct_internal(
|
return log_struct_internal(
|
||||||
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
|
level,
|
||||||
error,
|
error,
|
||||||
file, line, func,
|
file, line, func,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
||||||
@ -3902,7 +3902,7 @@ int json_log_internal(
|
|||||||
NULL);
|
NULL);
|
||||||
else if (source_line > 0 && source_column > 0)
|
else if (source_line > 0 && source_column > 0)
|
||||||
return log_struct_internal(
|
return log_struct_internal(
|
||||||
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
|
level,
|
||||||
error,
|
error,
|
||||||
file, line, func,
|
file, line, func,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
||||||
@ -3912,7 +3912,7 @@ int json_log_internal(
|
|||||||
NULL);
|
NULL);
|
||||||
else
|
else
|
||||||
return log_struct_internal(
|
return log_struct_internal(
|
||||||
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
|
level,
|
||||||
error,
|
error,
|
||||||
file, line, func,
|
file, line, func,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
"MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
|
||||||
|
|||||||
@ -66,26 +66,17 @@ static int print_catalog(FILE *f, sd_journal *j) {
|
|||||||
else
|
else
|
||||||
prefix = "--";
|
prefix = "--";
|
||||||
|
|
||||||
if (colors_enabled())
|
newline = strjoina(ansi_normal(), "\n", ansi_grey(), prefix, ansi_normal(), " ", ansi_green());
|
||||||
newline = strjoina(ANSI_NORMAL "\n", ansi_grey(), prefix, ANSI_NORMAL " ", ansi_green());
|
|
||||||
else
|
|
||||||
newline = strjoina("\n", prefix, " ");
|
|
||||||
|
|
||||||
z = strreplace(strstrip(t), "\n", newline);
|
z = strreplace(strstrip(t), "\n", newline);
|
||||||
if (!z)
|
if (!z)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
if (colors_enabled())
|
fprintf(f, "%s%s %s%s", ansi_grey(), prefix, ansi_normal(), ansi_green());
|
||||||
fprintf(f, "%s%s %s%s", ansi_grey(), prefix, ANSI_NORMAL, ansi_green());
|
|
||||||
else
|
|
||||||
fprintf(f, "%s ", prefix);
|
|
||||||
|
|
||||||
fputs(z, f);
|
fputs(z, f);
|
||||||
|
|
||||||
if (colors_enabled())
|
fprintf(f, "%s\n", ansi_normal());
|
||||||
fputs(ANSI_NORMAL "\n", f);
|
|
||||||
else
|
|
||||||
fputc('\n', f);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,7 @@ int udev_parse_config_full(
|
|||||||
|
|
||||||
/* we set the udev log level here explicitly, this is supposed
|
/* we set the udev log level here explicitly, this is supposed
|
||||||
* to regulate the code in libudev/ and udev/. */
|
* to regulate the code in libudev/ and udev/. */
|
||||||
r = log_set_max_level_from_string_realm(LOG_REALM_UDEV, log);
|
r = log_set_max_level_from_string(log);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
|
log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r,
|
||||||
"failed to set udev log level '%s', ignoring: %m", log);
|
"failed to set udev log level '%s', ignoring: %m", log);
|
||||||
|
|||||||
@ -527,7 +527,7 @@ tests += [
|
|||||||
libkmod,
|
libkmod,
|
||||||
libacl,
|
libacl,
|
||||||
libselinux],
|
libselinux],
|
||||||
udev_includes, '', 'manual', '-DLOG_REALM=LOG_REALM_UDEV'],
|
udev_includes, '', 'manual'],
|
||||||
|
|
||||||
[['src/test/test-udev-util.c']],
|
[['src/test/test-udev-util.c']],
|
||||||
|
|
||||||
|
|||||||
@ -9,15 +9,6 @@
|
|||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
assert_cc(LOG_REALM_REMOVE_LEVEL(LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, LOG_FTP | LOG_DEBUG))
|
|
||||||
== LOG_REALM_SYSTEMD);
|
|
||||||
assert_cc(LOG_REALM_REMOVE_LEVEL(LOG_REALM_PLUS_LEVEL(LOG_REALM_UDEV, LOG_LOCAL7 | LOG_DEBUG))
|
|
||||||
== LOG_REALM_UDEV);
|
|
||||||
assert_cc((LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, LOG_LOCAL3 | LOG_DEBUG) & LOG_FACMASK)
|
|
||||||
== LOG_LOCAL3);
|
|
||||||
assert_cc((LOG_REALM_PLUS_LEVEL(LOG_REALM_UDEV, LOG_USER | LOG_INFO) & LOG_PRIMASK)
|
|
||||||
== LOG_INFO);
|
|
||||||
|
|
||||||
assert_cc(IS_SYNTHETIC_ERRNO(SYNTHETIC_ERRNO(EINVAL)));
|
assert_cc(IS_SYNTHETIC_ERRNO(SYNTHETIC_ERRNO(EINVAL)));
|
||||||
assert_cc(!IS_SYNTHETIC_ERRNO(EINVAL));
|
assert_cc(!IS_SYNTHETIC_ERRNO(EINVAL));
|
||||||
assert_cc(IS_SYNTHETIC_ERRNO(SYNTHETIC_ERRNO(0)));
|
assert_cc(IS_SYNTHETIC_ERRNO(SYNTHETIC_ERRNO(0)));
|
||||||
|
|||||||
@ -15,10 +15,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
_cleanup_(unlink_tempfilep) char filename[] = "/tmp/fuzz-udev-rules.XXXXXX";
|
_cleanup_(unlink_tempfilep) char filename[] = "/tmp/fuzz-udev-rules.XXXXXX";
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!getenv("SYSTEMD_LOG_LEVEL")) {
|
if (!getenv("SYSTEMD_LOG_LEVEL"))
|
||||||
log_set_max_level_realm(LOG_REALM_UDEV, LOG_CRIT);
|
log_set_max_level(LOG_CRIT);
|
||||||
log_set_max_level_realm(LOG_REALM_SYSTEMD, LOG_CRIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_se(fmkostemp_safe(filename, "r+", &f) == 0);
|
assert_se(fmkostemp_safe(filename, "r+", &f) == 0);
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
|
|||||||
@ -112,7 +112,6 @@ libudevd_core = static_library(
|
|||||||
link_config_gperf_c,
|
link_config_gperf_c,
|
||||||
keyboard_keys_from_name_h,
|
keyboard_keys_from_name_h,
|
||||||
include_directories : udev_includes,
|
include_directories : udev_includes,
|
||||||
c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
|
|
||||||
link_with : udev_link_with,
|
link_with : udev_link_with,
|
||||||
dependencies : [libblkid, libkmod])
|
dependencies : [libblkid, libkmod])
|
||||||
|
|
||||||
@ -142,7 +141,6 @@ foreach prog : udev_id_progs
|
|||||||
name,
|
name,
|
||||||
prog,
|
prog,
|
||||||
include_directories : includes,
|
include_directories : includes,
|
||||||
c_args : ['-DLOG_REALM=LOG_REALM_UDEV'],
|
|
||||||
dependencies : [versiondep],
|
dependencies : [versiondep],
|
||||||
link_with : udev_link_with,
|
link_with : udev_link_with,
|
||||||
install_rpath : udev_rpath,
|
install_rpath : udev_rpath,
|
||||||
|
|||||||
@ -1868,7 +1868,7 @@ static int udev_rule_apply_token_to_event(
|
|||||||
if (level < 0)
|
if (level < 0)
|
||||||
level = event->default_log_level;
|
level = event->default_log_level;
|
||||||
|
|
||||||
log_set_max_level_all_realms(level);
|
log_set_max_level(level);
|
||||||
|
|
||||||
if (level == LOG_DEBUG && !event->log_level_was_debug) {
|
if (level == LOG_DEBUG && !event->log_level_was_debug) {
|
||||||
/* The log level becomes LOG_DEBUG at first time. Let's log basic information. */
|
/* The log level becomes LOG_DEBUG at first time. Let's log basic information. */
|
||||||
|
|||||||
@ -122,8 +122,6 @@ static int run(int argc, char *argv[]) {
|
|||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
log_set_max_level_realm(LOG_REALM_SYSTEMD, log_get_max_level());
|
|
||||||
|
|
||||||
r = mac_selinux_init();
|
r = mac_selinux_init();
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
@ -537,7 +537,7 @@ static int worker_device_monitor_handler(sd_device_monitor *monitor, sd_device *
|
|||||||
log_device_warning_errno(dev, r, "Failed to send signal to main daemon, ignoring: %m");
|
log_device_warning_errno(dev, r, "Failed to send signal to main daemon, ignoring: %m");
|
||||||
|
|
||||||
/* Reset the log level, as it might be changed by "OPTIONS=log_level=". */
|
/* Reset the log level, as it might be changed by "OPTIONS=log_level=". */
|
||||||
log_set_max_level_all_realms(manager->log_level);
|
log_set_max_level(manager->log_level);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1062,7 +1062,7 @@ static int on_ctrl_msg(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, co
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case UDEV_CTRL_SET_LOG_LEVEL:
|
case UDEV_CTRL_SET_LOG_LEVEL:
|
||||||
log_debug("Received udev control message (SET_LOG_LEVEL), setting log_level=%i", value->intval);
|
log_debug("Received udev control message (SET_LOG_LEVEL), setting log_level=%i", value->intval);
|
||||||
log_set_max_level_all_realms(value->intval);
|
log_set_max_level(value->intval);
|
||||||
manager->log_level = value->intval;
|
manager->log_level = value->intval;
|
||||||
manager_kill_workers(manager);
|
manager_kill_workers(manager);
|
||||||
break;
|
break;
|
||||||
@ -1852,8 +1852,6 @@ int run_udevd(int argc, char *argv[]) {
|
|||||||
log_set_max_level(LOG_DEBUG);
|
log_set_max_level(LOG_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_set_max_level_realm(LOG_REALM_SYSTEMD, log_get_max_level());
|
|
||||||
|
|
||||||
r = must_be_root();
|
r = must_be_root();
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user