summaryrefslogtreecommitdiff
path: root/src/logger
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-06-30 00:50:48 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-30 01:04:03 +0200
commit01c1ea14f79517ca829268a341da2eb60b7628f9 (patch)
tree9d8b97e5dc1c060aee0c59a75ee5261d55a3f46c /src/logger
parente01e34db22eb770efd0cb752bcfe4aad28157c93 (diff)
downloadbiboumi-01c1ea14f79517ca829268a341da2eb60b7628f9.tar.gz
biboumi-01c1ea14f79517ca829268a341da2eb60b7628f9.tar.bz2
biboumi-01c1ea14f79517ca829268a341da2eb60b7628f9.tar.xz
biboumi-01c1ea14f79517ca829268a341da2eb60b7628f9.zip
Use systemd-daemon logging prefix if available
Diffstat (limited to 'src/logger')
-rw-r--r--src/logger/logger.hpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/logger/logger.hpp b/src/logger/logger.hpp
index 182c517..b42681b 100644
--- a/src/logger/logger.hpp
+++ b/src/logger/logger.hpp
@@ -17,6 +17,17 @@
#define warning_lvl 2
#define error_lvl 3
+#include "config.h"
+
+#ifdef SYSTEMDDAEMON_FOUND
+# include <systemd/sd-daemon.h>
+#else
+# define SD_DEBUG "[ERROR]: "
+# define SD_INFO "[INFO]: "
+# define SD_WARNING "[WARNING]: "
+# define SD_ERR "[ERROR]: "
+#endif
+
// Macro defined to get the filename instead of the full path. But if it is
// not properly defined by the build system, we fallback to __FILE__
#ifndef __FILENAME__
@@ -27,16 +38,16 @@
__FILENAME__ << ":" << __LINE__
#define log_debug(text)\
- Logger::instance()->get_stream(debug_lvl) << "[DEBUG]:" << WHERE << ":\t" << text << std::endl;
+ Logger::instance()->get_stream(debug_lvl) << SD_DEBUG << WHERE << ":\t" << text << std::endl;
#define log_info(text)\
- Logger::instance()->get_stream(info_lvl) << "[INFO]:" << WHERE << ":\t" << text << std::endl;
+ Logger::instance()->get_stream(info_lvl) << SD_INFO << WHERE << ":\t" << text << std::endl;
#define log_warning(text)\
- Logger::instance()->get_stream(warning_lvl) << "[WARNING]:" << WHERE << ":\t" << text << std::endl;
+ Logger::instance()->get_stream(warning_lvl) << SD_WARNING << WHERE << ":\t" << text << std::endl;
#define log_error(text)\
- Logger::instance()->get_stream(error_lvl) << "[ERROR]:" << WHERE << ":\t" << text << std::endl;
+ Logger::instance()->get_stream(error_lvl) << SD_ERR << WHERE << ":\t" << text << std::endl;
/**
* Juste a structure representing a stream doing nothing with its input.