chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cgroup-show: remove duplicated check
[elogind.git]
/
src
/
shared
/
log.c
diff --git
a/src/shared/log.c
b/src/shared/log.c
index af1a932c86e9e37971c821f2e30b07d9a7481171..a870415a0065e202017d972942e20ed2daad2511 100644
(file)
--- a/
src/shared/log.c
+++ b/
src/shared/log.c
@@
-314,18
+314,23
@@
static int write_to_console(
const char *object,
const char *buffer) {
const char *object,
const char *buffer) {
- char location[64];
- struct iovec iovec[
5
] = {};
+ char location[64]
, prefix[1 + DECIMAL_STR_MAX(int) + 2]
;
+ struct iovec iovec[
6
] = {};
unsigned n = 0;
bool highlight;
if (console_fd < 0)
return 0;
unsigned n = 0;
bool highlight;
if (console_fd < 0)
return 0;
+ if (log_target == LOG_TARGET_CONSOLE_PREFIXED) {
+ sprintf(prefix, "<%i>", level);
+ IOVEC_SET_STRING(iovec[n++], prefix);
+ }
+
highlight = LOG_PRI(level) <= LOG_ERR && show_color;
if (show_location) {
highlight = LOG_PRI(level) <= LOG_ERR && show_color;
if (show_location) {
- snprintf(location, sizeof(location), "(%s:%
u
) ", file, line);
+ snprintf(location, sizeof(location), "(%s:%
i
) ", file, line);
char_array_0(location);
IOVEC_SET_STRING(iovec[n++], location);
}
char_array_0(location);
IOVEC_SET_STRING(iovec[n++], location);
}
@@
-1016,7
+1021,8
@@
int log_show_location_from_string(const char *e) {
}
bool log_on_console(void) {
}
bool log_on_console(void) {
- if (log_target == LOG_TARGET_CONSOLE)
+ if (log_target == LOG_TARGET_CONSOLE ||
+ log_target == LOG_TARGET_CONSOLE_PREFIXED)
return true;
return syslog_fd < 0 && kmsg_fd < 0 && journal_fd < 0;
return true;
return syslog_fd < 0 && kmsg_fd < 0 && journal_fd < 0;
@@
-1024,6
+1030,7
@@
bool log_on_console(void) {
static const char *const log_target_table[_LOG_TARGET_MAX] = {
[LOG_TARGET_CONSOLE] = "console",
static const char *const log_target_table[_LOG_TARGET_MAX] = {
[LOG_TARGET_CONSOLE] = "console",
+ [LOG_TARGET_CONSOLE_PREFIXED] = "console-prefixed",
[LOG_TARGET_KMSG] = "kmsg",
[LOG_TARGET_JOURNAL] = "journal",
[LOG_TARGET_JOURNAL_OR_KMSG] = "journal-or-kmsg",
[LOG_TARGET_KMSG] = "kmsg",
[LOG_TARGET_JOURNAL] = "journal",
[LOG_TARGET_JOURNAL_OR_KMSG] = "journal-or-kmsg",
@@
-1043,7
+1050,7
@@
void log_received_signal(int level, const struct signalfd_siginfo *si) {
get_process_comm(si->ssi_pid, &p);
log_full(level,
get_process_comm(si->ssi_pid, &p);
log_full(level,
- "Received SIG%s from PID
"PID_FMT
" (%s).",
+ "Received SIG%s from PID
%"PRIu32
" (%s).",
signal_to_string(si->ssi_signo),
si->ssi_pid, strna(p));
} else
signal_to_string(si->ssi_signo),
si->ssi_pid, strna(p));
} else