15 ZERO // log absolutely nothing
18 extern LogLevel log_level;
19 extern bool log_to_console;
21 void log(LogLevel lvl, const char *msg) noexcept;
22 void logMsgBegin(LogLevel lvl, const char *msg) noexcept;
23 void logMsgPart(const char *msg) noexcept;
24 void logMsgEnd(const char *msg) noexcept;
25 void logServiceStarted(const char *service_name) noexcept;
26 void logServiceFailed(const char *service_name) noexcept;
27 void logServiceStopped(const char *service_name) noexcept;
29 // Convenience methods which perform type conversion of the argument.
30 // There is some duplication here that could possibly be avoided, but
31 // it doesn't seem like a big deal.
32 static inline void log(LogLevel lvl, const std::string &str) noexcept
34 log(lvl, str.c_str());
37 static inline void logMsgBegin(LogLevel lvl, const std::string &str) noexcept
39 logMsgBegin(lvl, str.c_str());
42 static inline void logMsgBegin(LogLevel lvl, int a) noexcept
44 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
46 snprintf(nbuf, bufsz, "%d", a);
47 logMsgBegin(lvl, nbuf);
50 static inline void logMsgPart(const std::string &str) noexcept
52 logMsgPart(str.c_str());
55 static inline void logMsgPart(int a) noexcept
57 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
59 snprintf(nbuf, bufsz, "%d", a);
63 static inline void logMsgEnd(const std::string &str) noexcept
65 logMsgEnd(str.c_str());
68 static inline void logMsgEnd(int a) noexcept
70 constexpr int bufsz = (CHAR_BIT * sizeof(int) - 1) / 3 + 2;
72 snprintf(nbuf, bufsz, "%d", a);
76 static inline void logServiceStarted(const std::string &str) noexcept
78 logServiceStarted(str.c_str());
81 static inline void logServiceFailed(const std::string &str) noexcept
83 logServiceFailed(str.c_str());
86 static inline void logServiceStopped(const std::string &str) noexcept
88 logServiceStopped(str.c_str());
91 // It's not intended that methods in this namespace be called directly:
93 template <typename A> static inline void logParts(A a) noexcept
98 template <typename A, typename ...B> static inline void logParts(A a, B... b) noexcept
105 // Variadic 'log' method.
106 template <typename A, typename ...B> static inline void log(LogLevel lvl, A a, B ...b) noexcept
109 dinit_log::logParts(b...);