mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Log: Improve creation of log prefixes.
* this also fixes non whitespace seperated timestamps in logs after 95ebe4f31c @Aokromes
* remove an unnecessary stringstream in Log::outCommand
* delete copy constructor of LogMessage to prevent unwanted copies
This commit is contained in:
@@ -80,26 +80,13 @@ void Appender::write(LogMessage* message)
|
||||
std::ostringstream ss;
|
||||
|
||||
if (flags & APPENDER_FLAGS_PREFIX_TIMESTAMP)
|
||||
ss << message->getTimeStr();
|
||||
ss << message->getTimeStr() << ' ';
|
||||
|
||||
if (flags & APPENDER_FLAGS_PREFIX_LOGLEVEL)
|
||||
{
|
||||
if (ss.rdbuf()->in_avail() == 0)
|
||||
ss << ' ';
|
||||
|
||||
ss << Trinity::StringFormat("%-5s", Appender::getLogLevelString(message->level));
|
||||
}
|
||||
ss << Trinity::StringFormat("%-5s ", Appender::getLogLevelString(message->level));
|
||||
|
||||
if (flags & APPENDER_FLAGS_PREFIX_LOGFILTERTYPE)
|
||||
{
|
||||
if (ss.rdbuf()->in_avail() == 0)
|
||||
ss << ' ';
|
||||
|
||||
ss << '[' << message->type << ']';
|
||||
}
|
||||
|
||||
if (ss.rdbuf()->in_avail() == 0)
|
||||
ss << ' ';
|
||||
ss << '[' << message->type << "] ";
|
||||
|
||||
message->prefix = std::move(ss.str());
|
||||
_write(message);
|
||||
|
||||
@@ -62,6 +62,9 @@ struct LogMessage
|
||||
: level(_level), type(_type), text(std::forward<std::string>(_text)), mtime(time(NULL))
|
||||
{ }
|
||||
|
||||
LogMessage(LogMessage const& /*other*/) = delete;
|
||||
LogMessage& operator=(LogMessage const& /*other*/) = delete;
|
||||
|
||||
static std::string getTimeStr(time_t time);
|
||||
std::string getTimeStr();
|
||||
|
||||
|
||||
@@ -75,9 +75,7 @@ class Log
|
||||
|
||||
std::unique_ptr<LogMessage> msg(new LogMessage(LOG_LEVEL_INFO, "commands.gm", std::move(Trinity::StringFormat(fmt, args...))));
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << account;
|
||||
msg->param1 = ss.str();
|
||||
msg->param1 = std::to_string(account);
|
||||
|
||||
write(std::move(msg));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user