diff options
author | chai <chaifix@163.com> | 2021-10-18 02:12:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-18 02:12:30 +0800 |
commit | 22e576b5aa065f3cb2ca67a951af5e68063419a2 (patch) | |
tree | d72c6c77e33990cc70952c58e9ca50637ba6c242 /Editor/Utils/Log.cpp | |
parent | 7c8c68d79343d04be382334c15a73d079450857c (diff) |
*scripting
Diffstat (limited to 'Editor/Utils/Log.cpp')
-rw-r--r-- | Editor/Utils/Log.cpp | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/Editor/Utils/Log.cpp b/Editor/Utils/Log.cpp deleted file mode 100644 index 9ec7d42..0000000 --- a/Editor/Utils/Log.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "log.h" -#include <iostream> -#include <ctime> -#include <unordered_set> -#include "HelperFuncs.h" - -using namespace std; - -//long g_LogTags = LogTag::All; -unordered_set<string> s_OpenTags; - -#ifdef GAMELAB_DEBUG -// https://stackoverflow.com/questions/997946/how-to-get-current-time-and-date-in-c -// Get current date/time, format is YYYY-MM-DD.HH:mm:ss -const std::string currentDateTime() { - time_t now = time(0); - struct tm tstruct; - char buf[80]; - tstruct = *localtime(&now); - // Visit http://en.cppreference.com/w/cpp/chrono/c/strftime - // for more information about date/time format - strftime(buf, sizeof(buf), "%Y-%m-%d %X", &tstruct); - - return buf; -} - -void log_open_tag(std::string tag) -{ - s_OpenTags.insert(tag); -} - -// https://stackoverflow.com/questions/4053837/colorizing-text-in-the-console-with-c - -void log_info(std::string log) -{ - cout << "\x1B[97m" << currentDateTime() << " [Info] " << log << "\033[0m" << endl; -} - -void log_warning(std::string log) -{ - cout << "\x1B[93m" << currentDateTime() << " [Wanning] " << log << "\033[0m" << endl; -} - -void log_error(std::string log) -{ - cout << "\x1B[91m" << currentDateTime() << " [Error] " << log << "\033[0m" << endl; -} - -void log_error_null_param(std::string funcName, std::string param) -{ - log_error("Null parameter in " + funcName + " called " + param); -} - -void log_info(string tag, std::string log) -{ - if (s_OpenTags.count(tag) <= 0) - return; - log_info("[" + tag + "] " + log); -} -void log_warning(string tag, std::string log) -{ - if (s_OpenTags.count(tag) <= 0) - return; - log_warning("[" + tag + "] " + log); -} -void log_error(string tag, std::string log) -{ - if (s_OpenTags.count(tag) <= 0) - return; - log_error("[" + tag + "] " + log); -} -#else -void log_open_tag(std::string tag) {} -void log_info(std::string log) -{ -} - -void log_warning(std::string log) -{ -} - -void log_error(std::string log) -{ -} - -void log_error_null_param(std::string funcName, std::string param) -{ -} - -void log_info(string tag, std::string log) {} -void log_warning(string tag, std::string log) {} -void log_error(string tag, std::string log) {} - -#endif
\ No newline at end of file |