#include <sstream>
#include <systemd/sd-journal.h>
+#include <attributes/attributes.h>
+
extern int __alog_level;
+namespace {
+// One of these templates might not get instantiated, so they have to be marked as (possibly) unused
+ template <typename ...Args>
+ void UNUSED __ALOG_FUN(int level, const std::stringstream &format,
+ Args&&... args) {
+ sd_journal_print(level, format.str().c_str(), std::forward<Args>(args)...);
+ }
+ template <>
+ void UNUSED __ALOG_FUN(int level, const std::stringstream &format) {
+ sd_journal_print(level, "%s", format.str().c_str());
+ }
+}
+
#define __ALOG(LEVEL, FORMAT, ...) \
do { \
if (LEVEL <= __alog_level) { \
std::stringstream __LOG_MACRO_format; \
__LOG_MACRO_format << FORMAT; \
- sd_journal_print(LEVEL, __LOG_MACRO_format.str().c_str(), ##__VA_ARGS__); \
+ __ALOG_FUN(LEVEL, __LOG_MACRO_format, ##__VA_ARGS__); \
} \
} while (0)