chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
service: make sure we properly figure out whether a sysv service is enabled before...
[elogind.git]
/
src
/
log.c
diff --git
a/src/log.c
b/src/log.c
index 4f9f2da2592c5a99ad96eec34ba5d7b927afbbcb..21fc9f4fa091f9c40265d2f37d8d47a4cd0a80df 100644
(file)
--- a/
src/log.c
+++ b/
src/log.c
@@
-1,4
+1,4
@@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8
; indent-tabs-mode: nil
-*-*/
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-32,7
+32,6
@@
#include "macro.h"
#define SYSLOG_TIMEOUT_USEC (5*USEC_PER_SEC)
#include "macro.h"
#define SYSLOG_TIMEOUT_USEC (5*USEC_PER_SEC)
-#define LOG_BUFFER_MAX 1024
static LogTarget log_target = LOG_TARGET_CONSOLE;
static int log_max_level = LOG_INFO;
static LogTarget log_target = LOG_TARGET_CONSOLE;
static int log_max_level = LOG_INFO;
@@
-73,7
+72,7
@@
static int log_open_console(void) {
return console_fd;
}
return console_fd;
}
- log_
info
("Succesfully opened /dev/console for logging.");
+ log_
debug
("Succesfully opened /dev/console for logging.");
} else
console_fd = STDERR_FILENO;
} else
console_fd = STDERR_FILENO;
@@
-99,7
+98,7
@@
static int log_open_kmsg(void) {
return -errno;
}
return -errno;
}
- log_
info
("Succesfully opened /dev/kmsg for logging.");
+ log_
debug
("Succesfully opened /dev/kmsg for logging.");
return 0;
}
return 0;
}
@@
-146,7
+145,7
@@
static int log_open_syslog(void) {
goto fail;
}
goto fail;
}
- log_
info
("Succesfully opened syslog for logging.");
+ log_
debug
("Succesfully opened syslog for logging.");
return 0;
return 0;
@@
-227,10
+226,10
@@
static int write_to_console(
if (show_location)
IOVEC_SET_STRING(iovec[n++], location);
if (highlight)
if (show_location)
IOVEC_SET_STRING(iovec[n++], location);
if (highlight)
- IOVEC_SET_STRING(iovec[n++],
"\x1B[1;31m"
);
+ IOVEC_SET_STRING(iovec[n++],
ANSI_HIGHLIGHT_ON
);
IOVEC_SET_STRING(iovec[n++], buffer);
if (highlight)
IOVEC_SET_STRING(iovec[n++], buffer);
if (highlight)
- IOVEC_SET_STRING(iovec[n++],
"\x1B[0m"
);
+ IOVEC_SET_STRING(iovec[n++],
ANSI_HIGHLIGHT_OFF
);
IOVEC_SET_STRING(iovec[n++], "\n");
if (writev(console_fd, iovec, n) < 0)
IOVEC_SET_STRING(iovec[n++], "\n");
if (writev(console_fd, iovec, n) < 0)
@@
-265,7
+264,7
@@
static int write_to_syslog(
if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
return -EINVAL;
if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
return -EINVAL;
- snprintf(header_pid, sizeof(header_pid), "[%l
lu]: ", (unsigned long
long) getpid());
+ snprintf(header_pid, sizeof(header_pid), "[%l
u]: ", (unsigned
long) getpid());
char_array_0(header_pid);
zero(iovec);
char_array_0(header_pid);
zero(iovec);
@@
-279,7
+278,7
@@
static int write_to_syslog(
msghdr.msg_iov = iovec;
msghdr.msg_iovlen = ELEMENTSOF(iovec);
msghdr.msg_iov = iovec;
msghdr.msg_iovlen = ELEMENTSOF(iovec);
- if (sendmsg(syslog_fd, &msghdr,
0
) < 0)
+ if (sendmsg(syslog_fd, &msghdr,
MSG_NOSIGNAL
) < 0)
return -errno;
return 1;
return -errno;
return 1;
@@
-301,7
+300,7
@@
static int write_to_kmsg(
snprintf(header_priority, sizeof(header_priority), "<%i>", LOG_PRI(level));
char_array_0(header_priority);
snprintf(header_priority, sizeof(header_priority), "<%i>", LOG_PRI(level));
char_array_0(header_priority);
- snprintf(header_pid, sizeof(header_pid), "[%l
lu]: ", (unsigned long
long) getpid());
+ snprintf(header_pid, sizeof(header_pid), "[%l
u]: ", (unsigned
long) getpid());
char_array_0(header_pid);
zero(iovec);
char_array_0(header_pid);
zero(iovec);
@@
-331,7
+330,7
@@
static int log_dispatch(
do {
char *e;
do {
char *e;
- int k;
+ int k
= 0
;
buffer += strspn(buffer, NEWLINE);
buffer += strspn(buffer, NEWLINE);
@@
-344,24
+343,26
@@
static int log_dispatch(
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG) {
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG) {
- if ((
r
= write_to_syslog(level, file, line, func, buffer)) < 0) {
+ if ((
k
= write_to_syslog(level, file, line, func, buffer)) < 0) {
log_close_syslog();
log_open_kmsg();
log_close_syslog();
log_open_kmsg();
- } else if (
r
> 0)
+ } else if (
k
> 0)
r++;
}
r++;
}
- if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
- log_target == LOG_TARGET_KMSG) {
+ if (k <= 0 &&
+ (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
+ log_target == LOG_TARGET_KMSG)) {
- if ((
r
= write_to_kmsg(level, file, line, func, buffer)) < 0) {
+ if ((
k
= write_to_kmsg(level, file, line, func, buffer)) < 0) {
log_close_kmsg();
log_open_console();
log_close_kmsg();
log_open_console();
- } else if (
r
> 0)
+ } else if (
k
> 0)
r++;
}
r++;
}
- if ((k = write_to_console(level, file, line, func, buffer)) < 0)
+ if (k <= 0 &&
+ (k = write_to_console(level, file, line, func, buffer)) < 0)
return k;
buffer = e;
return k;
buffer = e;
@@
-398,7
+399,7
@@
int log_meta(
const char *func,
const char *format, ...) {
const char *func,
const char *format, ...) {
- char buffer[L
OG_BUFFER
_MAX];
+ char buffer[L
INE
_MAX];
int saved_errno, r;
va_list ap;
int saved_errno, r;
va_list ap;
@@
-425,7
+426,7
@@
void log_assert(
const char *func,
const char *format, ...) {
const char *func,
const char *format, ...) {
- static char buffer[L
OG_BUFFER
_MAX];
+ static char buffer[L
INE
_MAX];
int saved_errno = errno;
va_list ap;
int saved_errno = errno;
va_list ap;
@@
-474,11
+475,11
@@
void log_parse_environment(void) {
if (log_set_max_level_from_string(e) < 0)
log_warning("Failed to parse log level %s. Ignoring.", e);
if (log_set_max_level_from_string(e) < 0)
log_warning("Failed to parse log level %s. Ignoring.", e);
- if ((e = getenv("SYSTEMD_
SHOW
_COLOR")))
+ if ((e = getenv("SYSTEMD_
LOG
_COLOR")))
if (log_show_color_from_string(e) < 0)
log_warning("Failed to parse bool %s. Ignoring.", e);
if (log_show_color_from_string(e) < 0)
log_warning("Failed to parse bool %s. Ignoring.", e);
- if ((e = getenv("SYSTEMD_
SHOW
_LOCATION"))) {
+ if ((e = getenv("SYSTEMD_
LOG
_LOCATION"))) {
if (log_show_location_from_string(e) < 0)
log_warning("Failed to parse bool %s. Ignoring.", e);
}
if (log_show_location_from_string(e) < 0)
log_warning("Failed to parse bool %s. Ignoring.", e);
}