diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-04-07 07:06:13 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-04-07 07:06:13 +0200 |
commit | b2dec03e9b3df59550e598906a76e51bf721afa6 (patch) | |
tree | 604f6a258f90af0c46f84ded5522952d13072d82 /NitrokeyManager.cc | |
parent | d5ad36fab5ea6270ff6b0a8b14f8ce10f0fb3c34 (diff) | |
download | libnitrokey-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 'NitrokeyManager.cc')
-rw-r--r-- | NitrokeyManager.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index a4ce3a5..3af74ea 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -8,7 +8,7 @@ #include "include/misc.h" #include <mutex> #include "include/cxx_semantics.h" - +#include <functional> namespace nitrokey{ @@ -95,6 +95,12 @@ namespace nitrokey{ return device != nullptr; } + + void NitrokeyManager::set_log_function(std::function<void(std::string)> log_function){ + static nitrokey::log::FunctionalLogHandler handler(log_function); + nitrokey::log::Log::instance().set_handler(&handler); + } + bool NitrokeyManager::set_default_commands_delay(int delay){ if (delay < 20){ LOG("Delay set too low: " + to_string(delay), Loglevel::WARNING); |