CmLog.cpp 1.1 KB

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