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