1 // =================================
 2 // Copyright (c) 2021 Seppo Laakko
 3 // Distributed under the MIT license
 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& writerconst std::string& s);
34 LogFileWriter& operator<<(LogFileWriter& writerconst char* s);
35 LogFileWriter& operator<<(LogFileWriter& writerchar c);
36 LogFileWriter& operator<<(LogFileWriter& writerbool b);
37 LogFileWriter& operator<<(LogFileWriter& writerint x);
38 LogFileWriter& operator<<(LogFileWriter& writerdouble x);
39 LogFileWriter& operator<<(LogFileWriter& writerint64_t x);
40 LogFileWriter& operator<<(LogFileWriter& writeruint64_t x);
41 
42 } } // namespace soulng::util
43 
44 #endif // SOULNG_UTIL_LOG_FILE_INCLUDED