chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v231.2: Apply some minor style fixes
[elogind.git]
/
src
/
basic
/
log.c
diff --git
a/src/basic/log.c
b/src/basic/log.c
index aada46625ad31296f596231bf0556791a5fc8b96..da6aa409b5b99b7ebef64f2420627db857fe9b1a 100644
(file)
--- a/
src/basic/log.c
+++ b/
src/basic/log.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-21,16
+19,18
@@
#include <errno.h>
#include <fcntl.h>
#include <errno.h>
#include <fcntl.h>
-#ifdef __GLIBC__
-#include <printf.h>
-#else
-#include "parse-printf-format.h"
-#endif
+#include <inttypes.h>
+#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
+#include <string.h>
+#include <sys/signalfd.h>
#include <sys/socket.h>
#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
#include <sys/un.h>
#include <sys/un.h>
+#include <time.h>
#include <unistd.h>
#include "sd-messages.h"
#include <unistd.h>
#include "sd-messages.h"
@@
-52,6
+52,7
@@
#include "string-util.h"
#include "syslog-util.h"
#include "terminal-util.h"
#include "string-util.h"
#include "syslog-util.h"
#include "terminal-util.h"
+#include "time-util.h"
#include "util.h"
#define SNDBUF_SIZE (8*1024*1024)
#include "util.h"
#define SNDBUF_SIZE (8*1024*1024)
@@
-70,7
+71,9
@@
static bool syslog_is_stream = false;
static bool show_color = false;
static bool show_location = false;
static bool show_color = false;
static bool show_location = false;
-/// UNNEEDED by elogind static bool upgrade_syslog_to_journal = false;
+#if 0 /// UNNEEDED by elogind
+static bool upgrade_syslog_to_journal = false;
+#endif // 0
/* Akin to glibc's __abort_msg; which is private and we hence cannot
* use here. */
/* Akin to glibc's __abort_msg; which is private and we hence cannot
* use here. */
@@
-164,7
+167,7
@@
static int log_open_syslog(void) {
goto fail;
}
goto fail;
}
- if (connect(syslog_fd, &sa.sa,
offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path
)) < 0) {
+ if (connect(syslog_fd, &sa.sa,
SOCKADDR_UN_LEN(sa.un
)) < 0) {
safe_close(syslog_fd);
/* Some legacy syslog systems still use stream
safe_close(syslog_fd);
/* Some legacy syslog systems still use stream
@@
-176,7
+179,7
@@
static int log_open_syslog(void) {
goto fail;
}
goto fail;
}
- if (connect(syslog_fd, &sa.sa,
offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path
)) < 0) {
+ if (connect(syslog_fd, &sa.sa,
SOCKADDR_UN_LEN(sa.un
)) < 0) {
r = -errno;
goto fail;
}
r = -errno;
goto fail;
}
@@
-192,11
+195,13
@@
fail:
return r;
}
return r;
}
-#if 0 /// UNNEEDED by elogind
void log_close_journal(void) {
void log_close_journal(void) {
+#if 0 /// elogind does not support journald
journal_fd = safe_close(journal_fd);
journal_fd = safe_close(journal_fd);
+#endif // 0
}
}
+#if 0 /// UNNEEDED by elogind
static int log_open_journal(void) {
static const union sockaddr_union sa = {
static int log_open_journal(void) {
static const union sockaddr_union sa = {
@@
-215,7
+220,7
@@
static int log_open_journal(void) {
goto fail;
}
goto fail;
}
- if (connect(journal_fd, &sa.sa,
offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path
)) < 0) {
+ if (connect(journal_fd, &sa.sa,
SOCKADDR_UN_LEN(sa.un
)) < 0) {
r = -errno;
goto fail;
}
r = -errno;
goto fail;
}
@@
-238,7
+243,7
@@
int log_open(void) {
* because there is no reason to close it. */
if (log_target == LOG_TARGET_NULL) {
* because there is no reason to close it. */
if (log_target == LOG_TARGET_NULL) {
-
/// UNNEEDED by elogind
log_close_journal();
+ log_close_journal();
log_close_syslog();
log_close_console();
return 0;
log_close_syslog();
log_close_console();
return 0;
@@
-260,11
+265,12
@@
int log_open(void) {
}
}
#endif // 0
}
}
#endif // 0
+
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG) {
r = log_open_syslog();
if (r >= 0) {
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG) {
r = log_open_syslog();
if (r >= 0) {
-
/// UNNEEDED by elogind
log_close_journal();
+ log_close_journal();
log_close_console();
return r;
}
log_close_console();
return r;
}
@@
-272,12
+278,12
@@
int log_open(void) {
if (log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_SAFE ||
if (log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_SAFE ||
-
/// UNNEEDED by elogind
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
+ log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_KMSG) {
r = log_open_kmsg();
if (r >= 0) {
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_KMSG) {
r = log_open_kmsg();
if (r >= 0) {
-
/// UNNEEDED by elogind
log_close_journal();
+ log_close_journal();
log_close_syslog();
log_close_console();
return r;
log_close_syslog();
log_close_console();
return r;
@@
-285,7
+291,7
@@
int log_open(void) {
}
}
}
}
-
/// UNNEEDED by elogind
log_close_journal();
+ log_close_journal();
log_close_syslog();
return log_open_console();
log_close_syslog();
return log_open_console();
@@
-308,7
+314,7
@@
void log_set_target(LogTarget target) {
}
void log_close(void) {
}
void log_close(void) {
-
/// UNNEDED by elogind
log_close_journal();
+ log_close_journal();
log_close_syslog();
log_close_kmsg();
log_close_console();
log_close_syslog();
log_close_kmsg();
log_close_console();
@@
-340,7
+346,7
@@
static int write_to_console(
const char *object,
const char *buffer) {
const char *object,
const char *buffer) {
- char location[
64
], prefix[1 + DECIMAL_STR_MAX(int) + 2];
+ char location[
256
], prefix[1 + DECIMAL_STR_MAX(int) + 2];
struct iovec iovec[6] = {};
unsigned n = 0;
bool highlight;
struct iovec iovec[6] = {};
unsigned n = 0;
bool highlight;
@@
-622,7
+628,7
@@
static int log_dispatch(
(log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_SAFE ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
(log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_SAFE ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
-
/// UNNEEDED by elogind
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
+ log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_KMSG)) {
k = write_to_kmsg(level, error, file, line, func, object_field, object, buffer);
log_target == LOG_TARGET_KMSG)) {
k = write_to_kmsg(level, error, file, line, func, object_field, object, buffer);
@@
-785,7
+791,7
@@
static void log_assert(
return;
DISABLE_WARNING_FORMAT_NONLITERAL;
return;
DISABLE_WARNING_FORMAT_NONLITERAL;
-
snprintf(buffer, sizeof(buffer)
, format, text, file, line, func);
+
xsprintf(buffer
, format, text, file, line, func);
REENABLE_WARNING;
log_abort_msg = buffer;
REENABLE_WARNING;
log_abort_msg = buffer;