123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- static const std::regex _reg_file(R"(.*\\([\S]*[\.][\S]*)$)");
- static const std::regex _reg_file(R"(.*/([\S]*[\.][\S]*)$)");
- do{ \
- auto _now = std::chrono::system_clock::now(); \
- std::time_t _now_c = std::chrono::system_clock::to_time_t(_now); \
- std::string _log_time = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(_now_c)); \
- std::string _log_file_src = __FILE__; \
- auto _log_file = std::regex_replace(_log_file_src, _reg_file, "$1"); \
- std::string _log_str = fmt::format(__VA_ARGS__); \
- fmt::print(fg(fmt::color::blue), "[{}][{}][{}:{}] {}\n", _log_time, "DEBUG", _log_file , __LINE__ , _log_str); \
- }while(0)
- do{ \
- auto _now = std::chrono::system_clock::now(); \
- std::time_t _now_c = std::chrono::system_clock::to_time_t(_now); \
- std::string _log_time = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(_now_c)); \
- std::string _log_file_src = __FILE__; \
- auto _log_file = std::regex_replace(_log_file_src, _reg_file, "$1"); \
- std::string _log_str = fmt::format(__VA_ARGS__); \
- fmt::print(fg(fmt::color::green), "[{}][{}][{}:{}] {}\n", _log_time, "INFO", _log_file, __LINE__, _log_str); \
- }while(0)
- do{ \
- auto _now = std::chrono::system_clock::now(); \
- std::time_t _now_c = std::chrono::system_clock::to_time_t(_now); \
- std::string _log_time = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(_now_c)); \
- std::string _log_file_src = __FILE__; \
- auto _log_file = std::regex_replace(_log_file_src, _reg_file, "$1"); \
- std::string _log_str = fmt::format(__VA_ARGS__); \
- fmt::print(fg(fmt::color::yellow), "[{}][{}][{}:{}] {}\n", _log_time, "WARN", _log_file, __LINE__, _log_str); \
- }while(0)
- do{ \
- auto _now = std::chrono::system_clock::now(); \
- std::time_t _now_c = std::chrono::system_clock::to_time_t(_now); \
- std::string _log_time = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(_now_c)); \
- std::string _log_file_src = __FILE__; \
- auto _log_file = std::regex_replace(_log_file_src, _reg_file, "$1"); \
- std::string _log_str = fmt::format(__VA_ARGS__); \
- fmt::print(fg(fmt::color::red), "[{}][{}][{}:{}] {}\n", _log_time, "ERROR", _log_file, __LINE__, _log_str); \
- }while(0)
- do{ \
- auto _now = std::chrono::system_clock::now(); \
- std::time_t _now_c = std::chrono::system_clock::to_time_t(_now); \
- std::string _log_time = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(_now_c)); \
- std::string _log_file_src = __FILE__; \
- auto _log_file = std::regex_replace(_log_file_src, _reg_file, "$1"); \
- std::string _log_str = fmt::format(__VA_ARGS__); \
- fmt::print(fg(fmt::color::blue), "[{}][{}][{}:{}] {}", _log_time, "DEBUG", _log_file , __LINE__ , _log_str); \
- }while(0)
- do{ \
- auto _now = std::chrono::system_clock::now(); \
- std::time_t _now_c = std::chrono::system_clock::to_time_t(_now); \
- std::string _log_time = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(_now_c)); \
- std::string _log_file_src = __FILE__; \
- auto _log_file = std::regex_replace(_log_file_src, _reg_file, "$1"); \
- std::string _log_str = fmt::format(__VA_ARGS__); \
- fmt::print(fg(fmt::color::green), "[{}][{}][{}:{}] {}", _log_time, "INFO", _log_file, __LINE__, _log_str); \
- }while(0)
|