warnings
parent
43cf8c0ba1
commit
89bde7c6e8
|
@ -319,17 +319,17 @@ namespace blt::logging {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BLT_NOW() auto t = std::time(nullptr); auto now = std::localtime(&t)
|
#define BLT_NOW() auto t = std::time(nullptr); tm now; localtime_s(&now, &t); //auto now = std::localtime(&t)
|
||||||
#define BLT_ISO_YEAR(S) auto S = std::to_string(now->tm_year + 1900); \
|
#define BLT_ISO_YEAR(S) auto S = std::to_string(now.tm_year + 1900); \
|
||||||
S += '-'; \
|
S += '-'; \
|
||||||
S += ensureHasDigits(now->tm_mon+1, 2); \
|
S += ensureHasDigits(now.tm_mon+1, 2); \
|
||||||
S += '-'; \
|
S += '-'; \
|
||||||
S += ensureHasDigits(now->tm_mday, 2);
|
S += ensureHasDigits(now.tm_mday, 2);
|
||||||
#define BLT_CUR_TIME(S) auto S = ensureHasDigits(now->tm_hour, 2); \
|
#define BLT_CUR_TIME(S) auto S = ensureHasDigits(now.tm_hour, 2); \
|
||||||
S += ':'; \
|
S += ':'; \
|
||||||
S += ensureHasDigits(now->tm_min, 2); \
|
S += ensureHasDigits(now.tm_min, 2); \
|
||||||
S += ':'; \
|
S += ':'; \
|
||||||
S += ensureHasDigits(now->tm_sec, 2);
|
S += ensureHasDigits(now.tm_sec, 2);
|
||||||
|
|
||||||
static inline std::string ensureHasDigits(int current, int digits) {
|
static inline std::string ensureHasDigits(int current, int digits) {
|
||||||
std::string asString = std::to_string(current);
|
std::string asString = std::to_string(current);
|
||||||
|
@ -352,27 +352,27 @@ namespace blt::logging {
|
||||||
const std::unique_ptr<tag_map> tagMap = std::make_unique<tag_map>(tag_map{
|
const std::unique_ptr<tag_map> tagMap = std::make_unique<tag_map>(tag_map{
|
||||||
{"YEAR", [](const tag_func_param&) -> std::string {
|
{"YEAR", [](const tag_func_param&) -> std::string {
|
||||||
BLT_NOW();
|
BLT_NOW();
|
||||||
return std::to_string(now->tm_year);
|
return std::to_string(now.tm_year);
|
||||||
}},
|
}},
|
||||||
{"MONTH", [](const tag_func_param&) -> std::string {
|
{"MONTH", [](const tag_func_param&) -> std::string {
|
||||||
BLT_NOW();
|
BLT_NOW();
|
||||||
return ensureHasDigits(now->tm_mon+1, 2);
|
return ensureHasDigits(now.tm_mon+1, 2);
|
||||||
}},
|
}},
|
||||||
{"DAY", [](const tag_func_param&) -> std::string {
|
{"DAY", [](const tag_func_param&) -> std::string {
|
||||||
BLT_NOW();
|
BLT_NOW();
|
||||||
return ensureHasDigits(now->tm_mday, 2);
|
return ensureHasDigits(now.tm_mday, 2);
|
||||||
}},
|
}},
|
||||||
{"HOUR", [](const tag_func_param&) -> std::string {
|
{"HOUR", [](const tag_func_param&) -> std::string {
|
||||||
BLT_NOW();
|
BLT_NOW();
|
||||||
return ensureHasDigits(now->tm_hour, 2);
|
return ensureHasDigits(now.tm_hour, 2);
|
||||||
}},
|
}},
|
||||||
{"MINUTE", [](const tag_func_param&) -> std::string {
|
{"MINUTE", [](const tag_func_param&) -> std::string {
|
||||||
BLT_NOW();
|
BLT_NOW();
|
||||||
return ensureHasDigits(now->tm_min, 2);
|
return ensureHasDigits(now.tm_min, 2);
|
||||||
}},
|
}},
|
||||||
{"SECOND", [](const tag_func_param&) -> std::string {
|
{"SECOND", [](const tag_func_param&) -> std::string {
|
||||||
BLT_NOW();
|
BLT_NOW();
|
||||||
return ensureHasDigits(now->tm_sec, 2);
|
return ensureHasDigits(now.tm_sec, 2);
|
||||||
}},
|
}},
|
||||||
{"MS", [](const tag_func_param&) -> std::string {
|
{"MS", [](const tag_func_param&) -> std::string {
|
||||||
return std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(
|
return std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
@ -674,6 +674,11 @@ namespace blt::logging {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__) || defined(__llvm__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BLT_DISABLE_LOGGING
|
#ifdef BLT_DISABLE_LOGGING
|
||||||
#define BLT_LOG(format, level, ...)
|
#define BLT_LOG(format, level, ...)
|
||||||
#define BLT_LOG_STREAM(level)
|
#define BLT_LOG_STREAM(level)
|
||||||
|
@ -753,4 +758,8 @@ namespace blt::logging {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__) || defined(__llvm__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //BLT_TESTS_LOGGING2_H
|
#endif //BLT_TESTS_LOGGING2_H
|
||||||
|
|
|
@ -86,19 +86,21 @@ namespace blt::system
|
||||||
static inline std::string getTimeString()
|
static inline std::string getTimeString()
|
||||||
{
|
{
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
auto now = std::localtime(&t);
|
tm now{};
|
||||||
|
localtime_s(&now, &t);
|
||||||
|
//auto now = std::localtime(&t);
|
||||||
std::stringstream timeString;
|
std::stringstream timeString;
|
||||||
timeString << (1900 + now->tm_year);
|
timeString << (1900 + now.tm_year);
|
||||||
timeString << "-";
|
timeString << "-";
|
||||||
timeString << (1 + now->tm_mon);
|
timeString << (1 + now.tm_mon);
|
||||||
timeString << "-";
|
timeString << "-";
|
||||||
timeString << now->tm_mday;
|
timeString << now.tm_mday;
|
||||||
timeString << " ";
|
timeString << " ";
|
||||||
timeString << now->tm_hour;
|
timeString << now.tm_hour;
|
||||||
timeString << ":";
|
timeString << ":";
|
||||||
timeString << now->tm_min;
|
timeString << now.tm_min;
|
||||||
timeString << ":";
|
timeString << ":";
|
||||||
timeString << now->tm_sec;
|
timeString << now.tm_sec;
|
||||||
return timeString.str();
|
return timeString.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,13 +112,15 @@ namespace blt::system
|
||||||
static inline std::string getTimeStringLog()
|
static inline std::string getTimeStringLog()
|
||||||
{
|
{
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
auto now = std::localtime(&t);
|
tm now{};
|
||||||
|
localtime_s(&now, &t);
|
||||||
|
//auto now = std::localtime(&t);
|
||||||
std::string timeString = "[";
|
std::string timeString = "[";
|
||||||
timeString += ensureHasDigits(now->tm_hour, 2);
|
timeString += ensureHasDigits(now.tm_hour, 2);
|
||||||
timeString += ":";
|
timeString += ":";
|
||||||
timeString += ensureHasDigits(now->tm_min, 2);
|
timeString += ensureHasDigits(now.tm_min, 2);
|
||||||
timeString += ":";
|
timeString += ":";
|
||||||
timeString += ensureHasDigits(now->tm_sec, 2);
|
timeString += ensureHasDigits(now.tm_sec, 2);
|
||||||
timeString += "] ";
|
timeString += "] ";
|
||||||
return timeString;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
@ -127,19 +131,21 @@ namespace blt::system
|
||||||
static inline std::string getTimeStringFS()
|
static inline std::string getTimeStringFS()
|
||||||
{
|
{
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
auto now = std::localtime(&t);
|
tm now{};
|
||||||
|
localtime_s(&now, &t);
|
||||||
|
//auto now = std::localtime(&t);
|
||||||
std::stringstream timeString;
|
std::stringstream timeString;
|
||||||
timeString << (1900 + now->tm_year);
|
timeString << (1900 + now.tm_year);
|
||||||
timeString << "-";
|
timeString << "-";
|
||||||
timeString << (1 + now->tm_mon);
|
timeString << (1 + now.tm_mon);
|
||||||
timeString << "-";
|
timeString << "-";
|
||||||
timeString << now->tm_mday;
|
timeString << now.tm_mday;
|
||||||
timeString << "_";
|
timeString << "_";
|
||||||
timeString << now->tm_hour;
|
timeString << now.tm_hour;
|
||||||
timeString << "-";
|
timeString << "-";
|
||||||
timeString << now->tm_min;
|
timeString << now.tm_min;
|
||||||
timeString << "-";
|
timeString << "-";
|
||||||
timeString << now->tm_sec;
|
timeString << now.tm_sec;
|
||||||
return timeString.str();
|
return timeString.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
namespace blt {
|
namespace blt {
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
|
||||||
static inline std::string _macro_filename(const std::string& path){
|
static inline std::string _macro_filename(const std::string& path){
|
||||||
auto paths = blt::string::split(path, "/");
|
auto paths = blt::string::split(path, "/");
|
||||||
auto final = paths[paths.size()-1];
|
auto final = paths[paths.size()-1];
|
||||||
|
@ -38,6 +39,7 @@ namespace blt {
|
||||||
return paths[paths.size()-2];
|
return paths[paths.size()-2];
|
||||||
return final;
|
return final;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void b_throw(const char* what, const char* path, int line)
|
void b_throw(const char* what, const char* path, int line)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +51,10 @@ namespace blt {
|
||||||
printStacktrace(messages, size, path, line);
|
printStacktrace(messages, size, path, line);
|
||||||
|
|
||||||
BLT_FREE_STACK_TRACE();
|
BLT_FREE_STACK_TRACE();
|
||||||
|
#else
|
||||||
|
(void) what;
|
||||||
|
(void) path;
|
||||||
|
(void) line;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +72,10 @@ namespace blt {
|
||||||
|
|
||||||
BLT_FREE_STACK_TRACE();
|
BLT_FREE_STACK_TRACE();
|
||||||
#endif
|
#endif
|
||||||
|
(void) expression;
|
||||||
|
(void) msg;
|
||||||
|
(void) path;
|
||||||
|
(void) line;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printStacktrace(char** messages, int size, const char* path, int line)
|
void printStacktrace(char** messages, int size, const char* path, int line)
|
||||||
|
@ -106,7 +116,12 @@ namespace blt {
|
||||||
|
|
||||||
BLT_ERROR(buffer);
|
BLT_ERROR(buffer);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void) size;
|
||||||
|
(void) path;
|
||||||
|
(void) line;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue