Merge branch 'master' of github.com:traintastic/traintastic
Dieser Commit ist enthalten in:
Commit
f7fd18ea1a
@ -41,11 +41,13 @@ void ConsoleLogger::write(const std::chrono::system_clock::time_point& time, std
|
||||
const auto us = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()) % 1000000;
|
||||
tm tm;
|
||||
|
||||
const char time_format[] = TRAINTASTIC_LOG_DATE_FORMAT " " TRAINTASTIC_LOG_TIME_FORMAT;
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_streamMutex);
|
||||
|
||||
std::ostream& ss = (isErrorLogMessage(code) || isCriticalLogMessage(code) || isFatalLogMessage(code)) ? std::cerr : std::cout;
|
||||
ss
|
||||
<< std::put_time(localTime(&systemTime, &tm), "%F %T") << '.' << std::setfill('0') << std::setw(6) << us.count() << ' '
|
||||
<< std::put_time(localTime(&systemTime, &tm), time_format) << '.' << std::setfill('0') << std::setw(6) << us.count() << ' '
|
||||
<< objectId << ' '
|
||||
<< logMessageChar(code) << std::setw(4) << logMessageNumber(code) << ": "
|
||||
<< message
|
||||
|
||||
@ -55,8 +55,10 @@ void FileLogger::write(const std::chrono::system_clock::time_point& time, std::s
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_fileMutex);
|
||||
|
||||
const char time_format[] = TRAINTASTIC_LOG_DATE_FORMAT ";" TRAINTASTIC_LOG_TIME_FORMAT;
|
||||
|
||||
m_file
|
||||
<< std::put_time(localTime(&systemTime, &tm), "%F;%T") << '.' << std::setfill('0') << std::setw(6) << us.count() << ';'
|
||||
<< std::put_time(localTime(&systemTime, &tm), time_format) << '.' << std::setfill('0') << std::setw(6) << us.count() << ';'
|
||||
<< objectId << ';'
|
||||
<< logMessageChar(code) << std::setw(4) << logMessageNumber(code) << ';'
|
||||
<< message
|
||||
|
||||
@ -29,6 +29,16 @@
|
||||
#include <chrono>
|
||||
#include <traintastic/enum/logmessage.hpp>
|
||||
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
//NOTE: MinGW does not yet support all C++11 std::put_time specifiers
|
||||
//See bug: https://sourceforge.net/p/mingw-w64/bugs/793
|
||||
#define TRAINTASTIC_LOG_DATE_FORMAT "%Y-%m-%d"
|
||||
#define TRAINTASTIC_LOG_TIME_FORMAT "%H:%M:%S"
|
||||
#else
|
||||
#define TRAINTASTIC_LOG_DATE_FORMAT "%F"
|
||||
#define TRAINTASTIC_LOG_TIME_FORMAT "%T"
|
||||
#endif
|
||||
|
||||
class Logger
|
||||
{
|
||||
protected:
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren