fix some error
This commit is contained in:
@@ -9,7 +9,6 @@ project(
|
|||||||
])
|
])
|
||||||
|
|
||||||
add_project_arguments (
|
add_project_arguments (
|
||||||
'-Wall',
|
|
||||||
'-Wpedantic',
|
'-Wpedantic',
|
||||||
'-Wno-shadow',
|
'-Wno-shadow',
|
||||||
'-Wno-unused-but-set-variable',
|
'-Wno-unused-but-set-variable',
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ project(
|
|||||||
])
|
])
|
||||||
|
|
||||||
add_project_arguments (
|
add_project_arguments (
|
||||||
'-Wall',
|
|
||||||
'-Wpedantic',
|
'-Wpedantic',
|
||||||
'-Wno-shadow',
|
'-Wno-shadow',
|
||||||
'-Wno-unused-but-set-variable',
|
'-Wno-unused-but-set-variable',
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|||||||
@@ -3,15 +3,20 @@
|
|||||||
#include <experimental/source_location>
|
#include <experimental/source_location>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#define DEF_LINE() std::to_string(std::experimental::source_location::current().line())
|
#define DEF_LINE() std::to_string(std::experimental::source_location::current().line())
|
||||||
#define DEF_LOCATION() std::experimental::source_location::current().file_name() + std::string(" : ") + DEF_LINE()
|
#define DEF_LOCATION() std::experimental::source_location::current().file_name() + std::string(" : ") + DEF_LINE()
|
||||||
#define DEF_FILE_NAME() std::experimental::source_location::current().file_name()
|
#define DEF_FILE_NAME() std::experimental::source_location::current().file_name()
|
||||||
|
|
||||||
|
#include "hack/logger/logger.hpp"
|
||||||
|
|
||||||
namespace hack::exception
|
namespace hack::exception
|
||||||
{
|
{
|
||||||
|
using JSON = nlohmann::json;
|
||||||
|
|
||||||
const std::string SET_LOG = "set_log";
|
const std::string SET_LOG = "set_log";
|
||||||
|
|
||||||
template<typename JSON>
|
|
||||||
class exception
|
class exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -21,7 +26,7 @@ namespace hack::exception
|
|||||||
public:
|
public:
|
||||||
void message(const std::string v) noexcept { m_message = v; };
|
void message(const std::string v) noexcept { m_message = v; };
|
||||||
void description(const std::string v) noexcept { m_description = v; };
|
void description(const std::string v) noexcept { m_description = v; };
|
||||||
void error(const std::exception& e) noexcept { m_error = e.what(); };
|
void system_error(const std::exception& e) noexcept { m_system_error = e.what(); };
|
||||||
void level(const std::string& v) noexcept { m_level = v; };
|
void level(const std::string& v) noexcept { m_level = v; };
|
||||||
|
|
||||||
template<typename Param>
|
template<typename Param>
|
||||||
@@ -47,6 +52,12 @@ namespace hack::exception
|
|||||||
error()(r);
|
error()(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void commit(const std::filesystem::path file_name = DEF_FILE_NAME(), std::string line = DEF_LINE())
|
||||||
|
{
|
||||||
|
error("")(file_name,":", line, " : [", m_level,"] ", m_message);
|
||||||
|
warn("")(m_location, ": ", m_description);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class log_level { LOW, MID, HIGHT };
|
enum class log_level { LOW, MID, HIGHT };
|
||||||
|
|
||||||
@@ -74,7 +85,7 @@ namespace hack::exception
|
|||||||
{
|
{
|
||||||
JSON j;
|
JSON j;
|
||||||
j["description"] = m_description;
|
j["description"] = m_description;
|
||||||
j["system_error"] = m_error;
|
j["system_error"] = m_system_error;
|
||||||
j["level"] = m_level;
|
j["level"] = m_level;
|
||||||
j["location"] = m_location;
|
j["location"] = m_location;
|
||||||
j["params"] = m_params;
|
j["params"] = m_params;
|
||||||
@@ -86,7 +97,7 @@ namespace hack::exception
|
|||||||
private:
|
private:
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
std::string m_description;
|
std::string m_description;
|
||||||
std::string m_error;
|
std::string m_system_error;
|
||||||
std::string m_location;
|
std::string m_location;
|
||||||
std::string m_level = log_converter(log_level::LOW);
|
std::string m_level = log_converter(log_level::LOW);
|
||||||
JSON m_params;
|
JSON m_params;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <experimental/source_location>
|
#include <experimental/source_location>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// #include "boost/type_index.hpp"
|
// #include "boost/type_index.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ headers = [
|
|||||||
'hack/utils/singleton.hpp',
|
'hack/utils/singleton.hpp',
|
||||||
'hack/utils/utils.hpp',
|
'hack/utils/utils.hpp',
|
||||||
|
|
||||||
'hack/view/color.hpp'
|
'hack/view/color.hpp',
|
||||||
|
|
||||||
|
'hack/exception/exception.hpp'
|
||||||
]
|
]
|
||||||
|
|
||||||
sources = []
|
sources = []
|
||||||
|
|||||||
Reference in New Issue
Block a user