mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-04-21 12:20:46 +03:00
TMP / Fixed logging.cpp
This commit is contained in:
parent
08b5661934
commit
2fb324672a
@ -20,7 +20,7 @@ class LogSinkBackend {
|
||||
void flush();
|
||||
|
||||
public:
|
||||
LogSinkBackend() {}
|
||||
LogSinkBackend() = default;
|
||||
|
||||
std::ostream &getOutput() { return buffer; }
|
||||
|
||||
@ -51,8 +51,11 @@ std::ofstream openLogFile() {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables): TODO
|
||||
std::mutex logFileMutex;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
std::ofstream logFile = openLogFile();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local detail::LogSinkBackend theBackend;
|
||||
|
||||
std::ostream &detail::LogSink::getStream() const {
|
||||
@ -77,7 +80,7 @@ detail::LogSink::~LogSink() {
|
||||
}
|
||||
}
|
||||
|
||||
detail::LogSink::LogSink(LogSink &&moveFrom)
|
||||
detail::LogSink::LogSink(LogSink &&moveFrom) noexcept
|
||||
: isCurrentSink(moveFrom.isCurrentSink) {
|
||||
moveFrom.isCurrentSink = false;
|
||||
}
|
||||
@ -98,6 +101,7 @@ void detail::LogSinkBackend::flush() {
|
||||
namespace {
|
||||
// FIXME This approach is horribly inefficient. It is also unsafe if any
|
||||
// other piece of code wants access to std::localtime.
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
std::mutex getLocalTimeMutex;
|
||||
std::tm getLocalTimeAndDontExplodePlease() {
|
||||
std::lock_guard<std::mutex> lock(getLocalTimeMutex);
|
||||
|
@ -23,7 +23,7 @@ class LogSink : private progressia::main::NonCopyable {
|
||||
LogSink(bool isCurrentSink);
|
||||
~LogSink();
|
||||
|
||||
LogSink(LogSink &&);
|
||||
LogSink(LogSink &&) noexcept;
|
||||
|
||||
template <typename T>
|
||||
friend const LogSink &operator<<(const LogSink &sink, const T &x) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user