X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Flog.h;h=8619301e1ff62ca868d11744029c9d3a67ec1a7d;hp=0a7acb98ec912078c19b0a5d6317e6a5baca0b18;hb=9b00a533195b7fec54a791ca02090e0799214770;hpb=da2587d5154e11d4e643e326793f3ce2cc48dee6 diff --git a/src/basic/log.h b/src/basic/log.h index 0a7acb98e..8619301e1 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - #pragma once /*** @@ -26,6 +24,7 @@ #include #include #include +#include #include #include "sd-id128.h" @@ -36,10 +35,8 @@ typedef enum LogTarget{ LOG_TARGET_CONSOLE, LOG_TARGET_CONSOLE_PREFIXED, LOG_TARGET_KMSG, -#if 0 /// elogind does not support logging to systemd-journald LOG_TARGET_JOURNAL, LOG_TARGET_JOURNAL_OR_KMSG, -#endif // 0 LOG_TARGET_SYSLOG, LOG_TARGET_SYSLOG_OR_KMSG, LOG_TARGET_AUTO, /* console if stderr is tty, JOURNAL_OR_KMSG otherwise */ @@ -72,10 +69,9 @@ void log_close(void); #if 0 /// UNNEEDED by elogind void log_forget_fds(void); #endif // 0 + void log_close_syslog(void); -#if 0 /// UNNEEDED by elogind void log_close_journal(void); -#endif // 0 void log_close_kmsg(void); void log_close_console(void); @@ -106,18 +102,22 @@ int log_object_internal( const char *func, const char *object_field, const char *object, - const char *format, ...) _printf_(8,9); + const char *extra_field, + const char *extra, + const char *format, ...) _printf_(10,11); int log_object_internalv( int level, int error, - const char*file, + const char *file, int line, const char *func, const char *object_field, const char *object, + const char *extra_field, + const char *extra, const char *format, - va_list ap) _printf_(8,0); + va_list ap) _printf_(9,0); int log_struct_internal( int level, @@ -132,6 +132,15 @@ int log_oom_internal( int line, const char *func); +int log_format_iovec( + struct iovec *iovec, + unsigned iovec_len, + unsigned *n, + bool newline_separator, + int error, + const char *format, + va_list ap); + /* This modifies the buffer passed! */ int log_dump_internal( int level, @@ -190,15 +199,14 @@ void log_assert_failed_return( #ifdef LOG_TRACE # define log_trace(...) log_debug(__VA_ARGS__) #else -# define log_trace(...) do {} while(0) +# define log_trace(...) do {} while (0) #endif #ifdef ENABLE_DEBUG_ELOGIND # define log_debug_elogind(...) log_debug(__VA_ARGS__);usleep(25*USEC_PER_MSEC) #else -# define log_debug_elogind(...) do {} while(0) +# define log_debug_elogind(...) do {} while (0) #endif // ENABLE_DEBUG_ELOGIND - /* Structured logging */ #define log_struct(level, ...) log_struct_internal(level, 0, __FILE__, __LINE__, __func__, __VA_ARGS__) #define log_struct_errno(level, error, ...) log_struct_internal(level, error, __FILE__, __LINE__, __func__, __VA_ARGS__) @@ -213,15 +221,15 @@ bool log_on_console(void) _pure_; const char *log_target_to_string(LogTarget target) _const_; LogTarget log_target_from_string(const char *s) _pure_; -/* Helpers to prepare various fields for structured logging */ +/* Helper to prepare various field for structured logging */ #define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__ -#define LOG_MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x) #if 0 /// UNNEEDED by elogind void log_received_signal(int level, const struct signalfd_siginfo *si); void log_set_upgrade_syslog_to_journal(bool b); #endif // 0 +void log_set_always_reopen_console(bool b); int log_syntax_internal( const char *unit, @@ -251,5 +259,4 @@ int log_syntax_internal( log_syntax_internal(unit, _level, config_file, config_line, 0, __FILE__, __LINE__, __func__, \ "String is not UTF-8 clean, ignoring assignment: %s", strna(_p)); \ } \ - -EINVAL; \ })