Log.cpp 641 B

1234567891011121314151617181920212223242526272829
  1. #include "Log.h"
  2. #include <cassert>
  3. #include <memory>
  4. using namespace WallpaperEngine::Logging;
  5. Log::Log () { assert (this->sInstance == nullptr); }
  6. Log& Log::get () {
  7. static Log* const instance = [] {
  8. sInstance = std::unique_ptr<Log> (new Log ());
  9. return sInstance.get ();
  10. }();
  11. return *instance;
  12. }
  13. void Log::addOutput (std::ostream* stream) {
  14. const Debugging::LockGuard lock (this->mMutex);
  15. this->mOutputs.push_back (stream);
  16. }
  17. void Log::addError (std::ostream* stream) {
  18. const Debugging::LockGuard lock (this->mMutex);
  19. this->mErrors.push_back (stream);
  20. }
  21. std::unique_ptr<Log> Log::sInstance = nullptr;