From cc71df8100b33904d2c12a92fef237bebacbe1cd Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 12 May 2017 20:44:42 +0200 Subject: Refactor log code Inverse log levels order. Allow to change logging level with int. Signed-off-by: Szczepan Zalega --- include/log.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include/log.h') 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 log_function; + using log_function_type = std::function; + log_function_type log_function; public: - FunctionalLogHandler(std::function _log_function); + FunctionalLogHandler(log_function_type _log_function); virtual void print(const std::string &, Loglevel lvl); }; -- cgit v1.2.1