1
2
3
4
5
6 #ifndef SOULNG_UTIL_LOG_FILE_INCLUDED
7 #define SOULNG_UTIL_LOG_FILE_INCLUDED
8 #include <soulng/util/UtilApi.hpp>
9 #include <string>
10 #include <fstream>
11
12 namespace soulng { namespace util {
13
14 class LogFileWriter
15 {
16 public:
17 LogFileWriter(const std::string& logFilePath_, bool open_);
18 LogFileWriter(const std::string& logFilePath);
19 void WriteCurrentDateTime();
20 void WriteLine();
21 void WriteLine(const std::string& line);
22 void Write(const std::string& s);
23 typedef std::basic_ostream<char, std::char_traits<char>> CoutType;
24 typedef CoutType& (*StandardEndLine)(CoutType&);
25 LogFileWriter& operator<<(StandardEndLine manip);
26 std::ostream& LogFile() { return logFile; }
27 private:
28 bool open;
29 std::string logFilePath;
30 std::ofstream logFile;
31 };
32
33 LogFileWriter& operator<<(LogFileWriter& writer, const std::string& s);
34 LogFileWriter& operator<<(LogFileWriter& writer, const char* s);
35 LogFileWriter& operator<<(LogFileWriter& writer, char c);
36 LogFileWriter& operator<<(LogFileWriter& writer, bool b);
37 LogFileWriter& operator<<(LogFileWriter& writer, int x);
38 LogFileWriter& operator<<(LogFileWriter& writer, double x);
39 LogFileWriter& operator<<(LogFileWriter& writer, int64_t x);
40 LogFileWriter& operator<<(LogFileWriter& writer, uint64_t x);
41
42 } }
43
44 #endif // SOULNG_UTIL_LOG_FILE_INCLUDED