Browse Source

dont break log lines when logging to stderr

pull/53/head
Richard Fuchs 11 years ago
parent
commit
d0beccbd93
3 changed files with 7 additions and 8 deletions
  1. +5
    -8
      daemon/log.c
  2. +1
    -0
      daemon/log.h
  3. +1
    -0
      daemon/main.c

+ 5
- 8
daemon/log.c View File

@ -16,10 +16,7 @@ volatile gint log_level = LOG_INFO;
volatile gint log_level = LOG_DEBUG;
#endif
#ifndef MAX_LOG_LINE_LENGTH
#define MAX_LOG_LINE_LENGTH 500
#endif
unsigned int max_log_line_length = 500;
write_log_t write_log = (write_log_t) syslog;
const _fac_code_t _facilitynames[] =
@ -157,10 +154,10 @@ void ilog(int prio, const char *fmt, ...) {
piece = msg;
while (ret > MAX_LOG_LINE_LENGTH) {
write_log(xprio, "%s%s%.*s ...", prefix, infix, MAX_LOG_LINE_LENGTH, piece);
ret -= MAX_LOG_LINE_LENGTH;
piece += MAX_LOG_LINE_LENGTH;
while (max_log_line_length && ret > max_log_line_length) {
write_log(xprio, "%s%s%.*s ...", prefix, infix, max_log_line_length, piece);
ret -= max_log_line_length;
piece += max_log_line_length;
infix = "... ";
}


+ 1
- 0
daemon/log.h View File

@ -38,6 +38,7 @@ void log_to_stderr(int facility_priority, char *format, ...) __attribute__ ((for
extern struct log_info __thread log_info;
extern volatile gint log_level;
extern unsigned int max_log_line_length;


+ 1
- 0
daemon/main.c View File

@ -404,6 +404,7 @@ static void options(int *argc, char ***argv) {
if (_log_stderr) {
write_log = log_to_stderr;
max_log_line_length = 0;
}
}


Loading…
Cancel
Save