summaryrefslogtreecommitdiffstats
path: root/src/Logger.cpp
diff options
context:
space:
mode:
authorPeter Bell <peterbell10@live.co.uk>2020-05-15 18:23:22 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-05-16 10:39:05 +0200
commitc1e9d9d0e007a40f0913b83df0c5d33dbef3d97e (patch)
tree7e8664481eea05af68f343d7aa0fb09e25025e2b /src/Logger.cpp
parentEnable debug logging in test builds (diff)
downloadcuberite-c1e9d9d0e007a40f0913b83df0c5d33dbef3d97e.tar
cuberite-c1e9d9d0e007a40f0913b83df0c5d33dbef3d97e.tar.gz
cuberite-c1e9d9d0e007a40f0913b83df0c5d33dbef3d97e.tar.bz2
cuberite-c1e9d9d0e007a40f0913b83df0c5d33dbef3d97e.tar.lz
cuberite-c1e9d9d0e007a40f0913b83df0c5d33dbef3d97e.tar.xz
cuberite-c1e9d9d0e007a40f0913b83df0c5d33dbef3d97e.tar.zst
cuberite-c1e9d9d0e007a40f0913b83df0c5d33dbef3d97e.zip
Diffstat (limited to 'src/Logger.cpp')
-rw-r--r--src/Logger.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/Logger.cpp b/src/Logger.cpp
index 500007a84..05039cb1b 100644
--- a/src/Logger.cpp
+++ b/src/Logger.cpp
@@ -13,28 +13,25 @@
static void WriteLogOpener(fmt::memory_buffer & Buffer)
{
- time_t rawtime;
- time(&rawtime);
+ const time_t rawtime = time(nullptr);
- struct tm * timeinfo;
+ struct tm timeinfo;
#ifdef _MSC_VER
- struct tm timeinforeal;
- timeinfo = &timeinforeal;
- localtime_s(timeinfo, &rawtime);
+ localtime_s(&timeinfo, &rawtime);
#else
- timeinfo = localtime(&rawtime);
+ localtime_r(&rawtime, &timeinfo);
#endif
#ifdef _DEBUG
const auto ThreadID = std::hash<std::thread::id>()(std::this_thread::get_id());
fmt::format_to(
Buffer, "[{0:04x}|{1:02d}:{2:02d}:{3:02d}] ",
- ThreadID, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec
+ ThreadID, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec
);
#else
fmt::format_to(
Buffer, "[{0:02d}:{1:02d}:{2:02d}] ",
- timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec
+ timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec
);
#endif
}