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;
26 void log(LogLevel lvl, const char *msg) noexcept;
27 void logMsgBegin(LogLevel lvl, const char *msg) noexcept;
28 void logMsgPart(const char *msg) noexcept;
29 void logMsgEnd(const char *msg) noexcept;
30 void logServiceStarted(const char *service_name) noexcept;
31 void logServiceFailed(const char *service_name) noexcept;
32 void logServiceStopped(const char *service_name) noexcept;
34 // Convenience methods which perform type conversion of the argument.
35 // There is some duplication here that could possibly be avoided, but
36 // it doesn't seem like a big deal.
37 static inline void log(LogLevel lvl, const std::string &str) noexcept
39 log(lvl, str.c_str());
42 static inline void logMsgBegin(LogLevel lvl, const std::string &str) noexcept
44 logMsgBegin(lvl, str.c_str());
47 static inline void logMsgBegin(LogLevel lvl, int a) noexcept
49 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
51 snprintf(nbuf, bufsz, "%d", a);
52 logMsgBegin(lvl, nbuf);
55 static inline void logMsgPart(const std::string &str) noexcept
57 logMsgPart(str.c_str());
60 static inline void logMsgPart(int a) noexcept
62 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
64 snprintf(nbuf, bufsz, "%d", a);
68 static inline void logMsgEnd(const std::string &str) noexcept
70 logMsgEnd(str.c_str());
73 static inline void logMsgEnd(int a) noexcept
75 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
77 snprintf(nbuf, bufsz, "%d", a);
81 static inline void logServiceStarted(const std::string &str) noexcept
83 logServiceStarted(str.c_str());
86 static inline void logServiceFailed(const std::string &str) noexcept
88 logServiceFailed(str.c_str());
91 static inline void logServiceStopped(const std::string &str) noexcept
93 logServiceStopped(str.c_str());
96 // It's not intended that methods in this namespace be called directly:
98 template <typename A> static inline void logParts(A a) noexcept
103 template <typename A, typename ...B> static inline void logParts(A a, B... b) noexcept
110 // Variadic 'log' method.
111 template <typename A, typename ...B> static inline void log(LogLevel lvl, A a, B ...b) noexcept
114 dinit_log::logParts(b...);