diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-10-16 18:58:45 +0200 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2024-10-17 21:44:13 +0200 |
commit | 03312d4aa47995f5e9e48609b6dea5b385e2199e (patch) | |
tree | c6dbcc09e4e8ea2a910ec52a89c41588bfd28030 /src/common/Logging/Log.cpp | |
parent | fa5ba783853cb640a810be7c3d1e10d77cd53708 (diff) |
Core/Misc: Replace std::ostringstream based formatting with Trinity::StringFormat where possible in common and database projects
(cherry picked from commit 1a41281e37efdc4be602066dc3fdba12b24d1d0f)
Diffstat (limited to 'src/common/Logging/Log.cpp')
-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 */) |