remove log level
This commit is contained in:
parent
f40ee7b849
commit
99c0b73039
@ -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<typename Param>
|
||||
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<typename... Args>
|
||||
void set_variadic_params(Args... args)
|
||||
void variadic_params(Args... args)
|
||||
{
|
||||
int i = 0;
|
||||
([&] { m_params["arg_" + std::to_string(++i)] = args; }(), ...);
|
||||
}
|
||||
|
||||
template<typename Transaction>
|
||||
void set_transaction(Transaction& tr) { m_params["transaction"] = tr.convert_to_json(); }
|
||||
void transaction(Transaction& tr) { m_params["transaction"] = tr.convert_to_json(); }
|
||||
|
||||
template<typename Database>
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user