BsLog.cpp 959 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "BsLog.h"
  2. #include "BsException.h"
  3. namespace BansheeEngine
  4. {
  5. LogEntry::LogEntry(const String& msg, UINT32 channel)
  6. :mMsg(msg), mChannel(channel)
  7. { }
  8. Log::Log()
  9. {
  10. }
  11. Log::~Log()
  12. {
  13. BS_LOCK_RECURSIVE_MUTEX(mMutex);
  14. for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
  15. bs_delete(*iter);
  16. }
  17. void Log::logMsg(const String& message, UINT32 channel)
  18. {
  19. BS_LOCK_RECURSIVE_MUTEX(mMutex);
  20. LogEntry* newEntry = bs_new<LogEntry>(message, channel);
  21. mEntries.push_back(newEntry);
  22. doOnEntryAdded(*newEntry);
  23. }
  24. void Log::clear()
  25. {
  26. BS_LOCK_RECURSIVE_MUTEX(mMutex);
  27. for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
  28. bs_delete(*iter);
  29. mEntries.clear();
  30. }
  31. void Log::saveToFile(const Path& path)
  32. {
  33. // TODO - Save the log as HTML
  34. BS_EXCEPT(NotImplementedException, "Log save to file not yet implemented.");
  35. }
  36. void Log::doOnEntryAdded(const LogEntry& entry)
  37. {
  38. onEntryAdded(entry);
  39. }
  40. }