Merge branch 'master' of github.com:traintastic/traintastic

Dieser Commit ist enthalten in:
Reinder Feenstra 2023-02-18 23:14:40 +01:00
Commit f7fd18ea1a
3 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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

Datei anzeigen

@ -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: