aboutsummaryrefslogtreecommitdiff
path: root/include/log.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-04-07 07:06:13 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2017-04-07 07:06:13 +0200
commitb2dec03e9b3df59550e598906a76e51bf721afa6 (patch)
tree604f6a258f90af0c46f84ded5522952d13072d82 /include/log.h
parentd5ad36fab5ea6270ff6b0a8b14f8ce10f0fb3c34 (diff)
downloadlibnitrokey-b2dec03e9b3df59550e598906a76e51bf721afa6.tar.gz
libnitrokey-b2dec03e9b3df59550e598906a76e51bf721afa6.tar.bz2
Handle print function in logger by functor
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/log.h')
-rw-r--r--include/log.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/log.h b/include/log.h
index 38fc122..e7c790a 100644
--- a/include/log.h
+++ b/include/log.h
@@ -4,6 +4,8 @@
#include <string>
#include <cstddef>
+#include <functional>
+
namespace nitrokey {
namespace log {
@@ -29,6 +31,14 @@ namespace nitrokey {
virtual void print(const std::string &, Loglevel lvl);
};
+ class FunctionalLogHandler : public LogHandler {
+ std::function<void(std::string)> log_function;
+ public:
+ FunctionalLogHandler(std::function<void(std::string)> _log_function);
+ virtual void print(const std::string &, Loglevel lvl);
+
+ };
+
extern StdlogHandler stdlog_handler;
class Log {
@@ -56,8 +66,10 @@ namespace nitrokey {
#ifdef NO_LOG
#define LOG(string, level) while(false){}
+#define LOGD(string, level) while(false){}
#else
#define LOG(string, level) nitrokey::log::Log::instance()((string), (level))
+#define LOGD(string) nitrokey::log::Log::instance()((string), (nitrokey::log::Loglevel::DEBUG_L2))
#endif
#endif