X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Flog.h;h=0b82b768c97ac951f2bf96774b76a5242d42051a;hp=cedf881300d88eded8756681f78adfaf6e889d1e;hb=d72545b2a0c29e5844c508101cd4720c356193b4;hpb=89e750e26ce052aec7d38306328a0f52c90c5489 diff --git a/src/basic/log.h b/src/basic/log.h index cedf88130..0b82b768c 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 /*** @@ -21,14 +19,16 @@ along with systemd; If not, see . ***/ -#include +#include #include +#include #include -#include #include -#include +#include +#include #include "sd-id128.h" + #include "macro.h" typedef enum LogTarget{ @@ -66,7 +66,9 @@ int log_get_max_level(void) _pure_; int log_open(void); void log_close(void); -// UNNEEDED void log_forget_fds(void); +#if 0 /// UNNEEDED by elogind +void log_forget_fds(void); +#endif // 0 void log_close_syslog(void); void log_close_journal(void); @@ -126,6 +128,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, @@ -184,13 +195,13 @@ 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 */ @@ -211,9 +222,11 @@ LogTarget log_target_from_string(const char *s) _pure_; #define LOG_MESSAGE(fmt, ...) "MESSAGE=" fmt, ##__VA_ARGS__ #define LOG_MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x) -// UNNEEDED void log_received_signal(int level, const struct signalfd_siginfo *si); +#if 0 /// UNNEEDED by elogind +void log_received_signal(int level, const struct signalfd_siginfo *si); -// UNNEEDED void log_set_upgrade_syslog_to_journal(bool b); +void log_set_upgrade_syslog_to_journal(bool b); +#endif // 0 int log_syntax_internal( const char *unit, @@ -233,3 +246,14 @@ int log_syntax_internal( ? log_syntax_internal(unit, _level, config_file, config_line, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \ : -abs(_e); \ }) + +#define log_syntax_invalid_utf8(unit, level, config_file, config_line, rvalue) \ + ({ \ + int _level = (level); \ + if (log_get_max_level() >= LOG_PRI(_level)) { \ + _cleanup_free_ char *_p = NULL; \ + _p = utf8_escape_invalid(rvalue); \ + log_syntax_internal(unit, _level, config_file, config_line, 0, __FILE__, __LINE__, __func__, \ + "String is not UTF-8 clean, ignoring assignment: %s", strna(_p)); \ + } \ + })