diff --git a/src/hack/concepts/concepts.hpp b/src/hack/concepts/concepts.hpp index cc408f8..5367ee2 100755 --- a/src/hack/concepts/concepts.hpp +++ b/src/hack/concepts/concepts.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -48,5 +49,4 @@ namespace hack::concepts is_forward_list || std::is_array() || is_string), bool>() == true; - } diff --git a/src/hack/exception/exception.hpp b/src/hack/exception/exception.hpp index eb7d202..94f96aa 100644 --- a/src/hack/exception/exception.hpp +++ b/src/hack/exception/exception.hpp @@ -25,24 +25,24 @@ namespace hack void log() { - std::cout << view::color::bold << view::color::red <<"["+m_service+"] " << view::color::reset + std::cout << utils::color::bold << utils::color::red <<"["+m_service+"] " << utils::color::reset << m_location.file_name() << ":" - << view::color::italic << view::color::yellow << m_location.function_name() << "()" << view::color::reset - << view::color::bold << view::color::blue << "[" << m_location.line() << "]" << view::color::reset << ": " + << utils::color::italic << utils::color::yellow << m_location.function_name() << "()" << utils::color::reset + << utils::color::bold << utils::color::blue << "[" << m_location.line() << "]" << utils::color::reset << ": " << m_title << std::endl; if (!m_description.empty()) - std::cout << view::color::bold << view::color::red <<"["+m_service+"] " << view::color::reset + std::cout << utils::color::bold << utils::color::red <<"["+m_service+"] " << utils::color::reset << m_location.file_name() << ":" - << view::color::italic << view::color::yellow << m_location.function_name() << "()" << view::color::reset - << view::color::bold << view::color::blue << "[" << m_location.line() << "]" << view::color::reset << ": " + << utils::color::italic << utils::color::yellow << m_location.function_name() << "()" << utils::color::reset + << utils::color::bold << utils::color::blue << "[" << m_location.line() << "]" << utils::color::reset << ": " << m_description << std::endl; if (!m_system_error.empty()) - std::cout << view::color::bold << view::color::red <<"["+m_service+"] " << view::color::reset + std::cout << utils::color::bold << utils::color::red <<"["+m_service+"] " << utils::color::reset << m_location.file_name() << ":" - << view::color::italic << view::color::yellow << m_location.function_name() << "()" << view::color::reset - << view::color::bold << view::color::blue << "[" << m_location.line() << "]" << view::color::reset << ": " + << utils::color::italic << utils::color::yellow << m_location.function_name() << "()" << utils::color::reset + << utils::color::bold << utils::color::blue << "[" << m_location.line() << "]" << utils::color::reset << ": " << m_system_error << std::endl; } diff --git a/src/hack/logger/logger.hpp b/src/hack/logger/logger.hpp index ac3c0f2..6a65166 100755 --- a/src/hack/logger/logger.hpp +++ b/src/hack/logger/logger.hpp @@ -42,16 +42,16 @@ namespace hack void prepare(T t, U u) { std::cout << t - << u.file_name() << ":" << view::color::reset - << view::color::italic << view::color::yellow << u.function_name() << "()" << view::color::reset - << view::color::bold << view::color::blue << "[" << u.line() << "]" << view::color::reset << ": "; + << u.file_name() << ":" << utils::color::reset + << utils::color::italic << utils::color::yellow << u.function_name() << "()" << utils::color::reset + << utils::color::bold << utils::color::blue << "[" << u.line() << "]" << utils::color::reset << ": "; } static void print() { std::cout << std::endl; } static std::ostream& make_type_view(std::ostream &os) { - os << view::color::bold << view::color::green << "[ok]" << view::color::reset << view::color::green; + os << utils::color::bold << utils::color::green << "[ok]" << utils::color::reset << utils::color::green; return os; } @@ -171,7 +171,7 @@ namespace hack private: static std::ostream& make_type_view(std::ostream &os) { - os << view::color::bold << view::color::yellow << "[WARN]" << view::color::reset << view::color::yellow; + os << utils::color::bold << utils::color::yellow << "[WARN]" << utils::color::reset << utils::color::yellow; return os; } }; @@ -201,7 +201,7 @@ namespace hack private: static std::ostream& make_type_view(std::ostream &os) { - os << view::color::bold << view::color::red << "[ERROR]" << view::color::reset << view::color::red; + os << utils::color::bold << utils::color::red << "[ERROR]" << utils::color::reset << utils::color::red; return os; } }; diff --git a/src/hack/utils/color.hpp b/src/hack/utils/color.hpp index 3f3d37d..6173e3f 100755 --- a/src/hack/utils/color.hpp +++ b/src/hack/utils/color.hpp @@ -2,7 +2,7 @@ #include -namespace hack::view::color +namespace hack::utils::color { template std::basic_ostream& reset(std::basic_ostream &os) diff --git a/src/hack/utils/timestamp.hpp b/src/hack/utils/timestamp.hpp new file mode 100644 index 0000000..772a29b --- /dev/null +++ b/src/hack/utils/timestamp.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +namespace hack::utils +{ + // return current time + inline std::string timestamp() + { + auto now = std::chrono::system_clock::now(); + auto in_time_t = std::chrono::system_clock::to_time_t(now); + std::stringstream ss; + ss << std::put_time(std::localtime(&in_time_t), "%Y-%m-%d-%H.%M.%S"); + return ss.str(); + } +}