BsLog.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #include "BsLog.h"
  5. #include "BsException.h"
  6. namespace BansheeEngine
  7. {
  8. LogEntry::LogEntry(const String& msg, const String& level)
  9. :mMsg(msg), mChannel(level)
  10. { }
  11. Log::Log()
  12. {
  13. }
  14. Log::~Log()
  15. {
  16. BS_LOCK_RECURSIVE_MUTEX(mMutex);
  17. for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
  18. bs_delete<PoolAlloc>(*iter);
  19. }
  20. void Log::logMsg(const String& message, const String& level)
  21. {
  22. BS_LOCK_RECURSIVE_MUTEX(mMutex);
  23. LogEntry* newEntry = bs_new<LogEntry, PoolAlloc>(message, level);
  24. mEntries.push_back(newEntry);
  25. doOnEntryAdded(*newEntry);
  26. }
  27. void Log::clear()
  28. {
  29. BS_LOCK_RECURSIVE_MUTEX(mMutex);
  30. for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
  31. bs_delete<PoolAlloc>(*iter);
  32. mEntries.clear();
  33. }
  34. void Log::saveToFile(const WString& path)
  35. {
  36. // TODO - Save the log as HTML
  37. BS_EXCEPT(NotImplementedException, "Log save to file not yet implemented.");
  38. }
  39. void Log::doOnEntryAdded(const LogEntry& entry)
  40. {
  41. onEntryAdded(entry);
  42. }
  43. }