diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-10-16 18:58:45 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2024-10-16 18:58:45 +0200 |
commit | 1a41281e37efdc4be602066dc3fdba12b24d1d0f (patch) | |
tree | 1cca422ce96b71de18b686527bd1e0383b5166a9 /src/common/Logging | |
parent | c3b06d7797af2d13499680515ca94fc883cd343a (diff) |
Core/Misc: Replace std::ostringstream based formatting with Trinity::StringFormat where possible in common and database projects
Diffstat (limited to 'src/common/Logging')
-rw-r--r-- | src/common/Logging/Log.cpp | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index feefce33f1e..b64aec29866 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -27,7 +27,6 @@ #include "Strand.h" #include "StringConvert.h" #include "Util.h" -#include <sstream> Log::Log() : AppenderId(0), lowestLogLevel(LOG_LEVEL_FATAL), _ioContext(nullptr), _strand(nullptr) { @@ -265,27 +264,7 @@ Logger const* Log::GetLoggerByType(std::string_view type) const std::string Log::GetTimestampStr() { time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - - std::tm aTm; - localtime_r(&tt, &aTm); - - // YYYY year - // MM month (2 digits 01-12) - // DD day (2 digits 01-31) - // HH hour (2 digits 00-23) - // MM minutes (2 digits 00-59) - // SS seconds (2 digits 00-59) - try - { - return Trinity::StringFormat("{:04}-{:02}-{:02}_{:02}-{:02}-{:02}", - aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec); - } - catch (std::exception const& ex) - { - fprintf(stderr, "Failed to initialize timestamp part of log filename! %s", ex.what()); - fflush(stderr); - ABORT(); - } + return TimeToTimestampStr(tt); } bool Log::SetLogLevel(std::string const& name, int32 newLeveli, bool isLogger /* = true */) |