mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-06 12:27:48 +00:00
feat(Core/Time): Implement saparated manager for game time (#8630)
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#include "Log.h"
|
||||
#include "LogMessage.h"
|
||||
#include "StringConvert.h"
|
||||
#include "Util.h"
|
||||
#include "Timer.h"
|
||||
#include <algorithm>
|
||||
|
||||
AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, AppenderFlags flags, std::vector<std::string_view> const& args) :
|
||||
@@ -127,7 +127,7 @@ FILE* AppenderFile::OpenFile(std::string const& filename, std::string const& mod
|
||||
CloseFile();
|
||||
std::string newName(fullName);
|
||||
newName.push_back('.');
|
||||
newName.append(LogMessage::getTimeStr(time(nullptr)));
|
||||
newName.append(LogMessage::getTimeStr(GetEpochTime()));
|
||||
std::replace(newName.begin(), newName.end(), ':', '-');
|
||||
rename(fullName.c_str(), newName.c_str()); // no error handling... if we couldn't make a backup, just ignore
|
||||
}
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
#include "Timer.h"
|
||||
|
||||
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text)
|
||||
: level(_level), type(_type), text(std::forward<std::string>(_text)), mtime(time(nullptr))
|
||||
: level(_level), type(_type), text(std::forward<std::string>(_text)), mtime(GetEpochTime())
|
||||
{
|
||||
}
|
||||
|
||||
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text, std::string&& _param1)
|
||||
: level(_level), type(_type), text(std::forward<std::string>(_text)), param1(std::forward<std::string>(_param1)), mtime(time(nullptr))
|
||||
: level(_level), type(_type), text(std::forward<std::string>(_text)), param1(std::forward<std::string>(_param1)), mtime(GetEpochTime())
|
||||
{
|
||||
}
|
||||
|
||||
std::string LogMessage::getTimeStr(time_t time)
|
||||
std::string LogMessage::getTimeStr(Seconds time)
|
||||
{
|
||||
return Acore::Time::TimeToTimestampStr(Seconds(time), "%Y-%m-%d %X");
|
||||
return Acore::Time::TimeToTimestampStr(time, "%Y-%m-%d %X");
|
||||
}
|
||||
|
||||
std::string LogMessage::getTimeStr() const
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#define LogMessage_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include "Duration.h"
|
||||
#include "LogCommon.h"
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
|
||||
struct LogMessage
|
||||
@@ -31,7 +31,7 @@ struct LogMessage
|
||||
LogMessage(LogMessage const& /*other*/) = delete;
|
||||
LogMessage& operator=(LogMessage const& /*other*/) = delete;
|
||||
|
||||
static std::string getTimeStr(time_t time);
|
||||
static std::string getTimeStr(Seconds time);
|
||||
std::string getTimeStr() const;
|
||||
|
||||
LogLevel const level;
|
||||
@@ -39,7 +39,7 @@ struct LogMessage
|
||||
std::string const text;
|
||||
std::string prefix;
|
||||
std::string param1;
|
||||
time_t mtime;
|
||||
Seconds mtime;
|
||||
|
||||
///@ Returns size of the log message content in bytes
|
||||
uint32 Size() const
|
||||
|
||||
Reference in New Issue
Block a user