17 ZERO // log absolutely nothing
20 extern LogLevel log_level[2];
21 void enable_console_log(bool do_enable) noexcept;
22 void init_log(ServiceSet *sset);
23 void setup_main_log(int fd);
24 bool is_log_flushed() noexcept;
25 void discard_console_log_buffer() noexcept;
27 void log(LogLevel lvl, const char *msg) noexcept;
28 void logMsgBegin(LogLevel lvl, const char *msg) noexcept;
29 void logMsgPart(const char *msg) noexcept;
30 void logMsgEnd(const char *msg) noexcept;
31 void logServiceStarted(const char *service_name) noexcept;
32 void logServiceFailed(const char *service_name) noexcept;
33 void logServiceStopped(const char *service_name) noexcept;
35 // Convenience methods which perform type conversion of the argument.
36 // There is some duplication here that could possibly be avoided, but
37 // it doesn't seem like a big deal.
38 static inline void log(LogLevel lvl, const std::string &str) noexcept
40 log(lvl, str.c_str());
43 static inline void logMsgBegin(LogLevel lvl, const std::string &str) noexcept
45 logMsgBegin(lvl, str.c_str());
48 static inline void logMsgBegin(LogLevel lvl, int a) noexcept
50 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
52 snprintf(nbuf, bufsz, "%d", a);
53 logMsgBegin(lvl, nbuf);
56 static inline void logMsgPart(const std::string &str) noexcept
58 logMsgPart(str.c_str());
61 static inline void logMsgPart(int a) noexcept
63 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
65 snprintf(nbuf, bufsz, "%d", a);
69 static inline void logMsgEnd(const std::string &str) noexcept
71 logMsgEnd(str.c_str());
74 static inline void logMsgEnd(int a) noexcept
76 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
78 snprintf(nbuf, bufsz, "%d", a);
82 static inline void logServiceStarted(const std::string &str) noexcept
84 logServiceStarted(str.c_str());
87 static inline void logServiceFailed(const std::string &str) noexcept
89 logServiceFailed(str.c_str());
92 static inline void logServiceStopped(const std::string &str) noexcept
94 logServiceStopped(str.c_str());
97 // It's not intended that methods in this namespace be called directly:
99 template <typename A> static inline void logParts(A a) noexcept
104 template <typename A, typename ...B> static inline void logParts(A a, B... b) noexcept
111 // Variadic 'log' method.
112 template <typename A, typename ...B> static inline void log(LogLevel lvl, A a, B ...b) noexcept
115 dinit_log::logParts(b...);