From 99c0b73039a7dc74ae280955772f506f52bfc749 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Mon, 8 Jul 2024 10:40:18 +0300 Subject: [PATCH] remove log level --- src/hack/exception/exception.hpp | 33 ++++---------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/hack/exception/exception.hpp b/src/hack/exception/exception.hpp index a644a66..7a3a816 100644 --- a/src/hack/exception/exception.hpp +++ b/src/hack/exception/exception.hpp @@ -28,22 +28,21 @@ namespace hack void message(const std::string v) noexcept { m_message = v; }; void description(const std::string v) noexcept { m_description = v; }; void system_error(const std::exception& e) noexcept { m_system_error = e.what(); }; - void level(const std::string& v) noexcept { m_level = v; }; template - void set_params(std::string key, Param value) { m_params[key] = value; } + void params(std::string key, Param value) { m_params[key] = value; } // если что-то не значительное, но в больших обемах, то можноиспользовать этот метод // на выходе будет что-то типа { "arg_1" : 123, "arg_2" : "value" } template - void set_variadic_params(Args... args) + void variadic_params(Args... args) { int i = 0; ([&] { m_params["arg_" + std::to_string(++i)] = args; }(), ...); } template - void set_transaction(Transaction& tr) { m_params["transaction"] = tr.convert_to_json(); } + void transaction(Transaction& tr) { m_params["transaction"] = tr.convert_to_json(); } template void commit(const std::filesystem::path file_name = DEF_FILE_NAME(), std::string line = DEF_LINE()) @@ -54,39 +53,16 @@ namespace hack void commit(const std::filesystem::path file_name = DEF_FILE_NAME(), std::string line = DEF_LINE()) { - error("")(file_name,":", line, " : [", m_level,"] ", m_message); + error("")(file_name,":", line, ": ", m_message); warn("")(m_location, ": ", m_description); } - public: - enum class log_level { LOW, MID, HIGHT }; - private: - std::string log_converter(log_level ll) - { - std::string r; - switch (ll) - { - case log_level::LOW: - r = "LOW"; - break;; - case log_level::MID: - r = "MIDLE"; - break;; - default: - r = "HIGHT"; - break;; - } - - return r; - } - JSON convert_to_json() override { JSON j; j["description"] = m_description; j["system_error"] = m_system_error; - j["level"] = m_level; j["location"] = m_location; j["params"] = m_params; j["msg_to_front"] = m_message; @@ -99,7 +75,6 @@ namespace hack std::string m_description; std::string m_system_error; std::string m_location; - std::string m_level = log_converter(log_level::LOW); JSON m_params; }; }