aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/NitrokeyManager.h2
-rw-r--r--include/log.h13
2 files changed, 12 insertions, 3 deletions
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index e3dcc45..de14fbc 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -179,6 +179,8 @@ char * strndup(const char* str, size_t maxlen);
public:
bool set_current_device_speed(int retry_delay, int send_receive_delay);
void set_loglevel(Loglevel loglevel);
+
+ void set_loglevel(int loglevel);
};
}
diff --git a/include/log.h b/include/log.h
index e7c790a..e559845 100644
--- a/include/log.h
+++ b/include/log.h
@@ -16,7 +16,11 @@ namespace nitrokey {
enum class Loglevel : int {
- DEBUG_L2, DEBUG, INFO, WARNING, ERROR
+ ERROR,
+ WARNING,
+ INFO,
+ DEBUG,
+ DEBUG_L2
};
class LogHandler {
@@ -24,6 +28,8 @@ namespace nitrokey {
virtual void print(const std::string &, Loglevel lvl) = 0;
protected:
std::string loglevel_to_str(Loglevel);
+ std::string format_message_to_string(const std::string &str, const Loglevel &lvl);
+
};
class StdlogHandler : public LogHandler {
@@ -32,9 +38,10 @@ namespace nitrokey {
};
class FunctionalLogHandler : public LogHandler {
- std::function<void(std::string)> log_function;
+ using log_function_type = std::function<void(std::string)>;
+ log_function_type log_function;
public:
- FunctionalLogHandler(std::function<void(std::string)> _log_function);
+ FunctionalLogHandler(log_function_type _log_function);
virtual void print(const std::string &, Loglevel lvl);
};