/TGame/TUtil/Log/LogTargetFile.cpp

http://awoe.googlecode.com/ · C++ · 38 lines · 32 code · 6 blank · 0 comment · 2 complexity · dc31102f84342eac3949ae1e93be9f42 MD5 · raw file

  1. #include "stdafx.h"
  2. #include "LogTargetFile.h"
  3. #include <fstream>
  4. namespace woe
  5. {
  6. LogTargetFile::LogTargetFile(const string& file)
  7. :log_file_name_(file)
  8. {
  9. }
  10. LogTargetFile::~LogTargetFile()
  11. {
  12. }
  13. bool LogTargetFile::initialize()
  14. {
  15. log_file_stream_.open(log_file_name_.c_str(), std::ios_base::out | std::ios_base::trunc);
  16. if (log_file_stream_.good())
  17. {
  18. return true;
  19. }
  20. else
  21. {
  22. return false;
  23. }
  24. }
  25. void LogTargetFile::doLog(const string& msg, const string& ll, const TimeStamp& ts)
  26. {
  27. if (log_file_stream_.good())
  28. {
  29. log_file_stream_<<ts.getSeconds()<<ts.getMilliSeconds()<<" -"<<ll <<"> "<<msg;
  30. }
  31. }
  32. }