Cafu Engine
ConsoleFile.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_CONSOLE_FILE_HPP_INCLUDED
8 #define CAFU_CONSOLE_FILE_HPP_INCLUDED
9 
10 #include "Console.hpp"
11 
12 #include <fstream>
13 
14 
15 namespace cf
16 {
17  /// This class implements the ConsoleI interface by writing the console output into a text file.
18  class ConsoleFileT : public ConsoleI
19  {
20  public:
21 
22  /// Constructor for creating an instance of a ConsoleFileT.
23  /// @param FileName Path and name of the file that the console output is to be written to.
24  ConsoleFileT(const std::string& FileName);
25 
26  /// Sets if the console buffer should be auto-flushed after each call to one of the Print() or Warning() methods.
27  void SetAutoFlush(bool AutoFlush) { m_AutoFlush=AutoFlush; }
28 
29  /// Flushes the buffers so that all contents is immediately written into the file.
30  void Flush();
31 
32  // Methods of the ConsoleI interface.
33  void Print(const std::string& s);
34  void DevPrint(const std::string& s);
35  void Warning(const std::string& s);
36  void DevWarning(const std::string& s);
37 
38 
39  private:
40 
41  std::ofstream m_File; ///< The filestream output is logged to.
42  bool m_AutoFlush; ///< If the console buffer should be auto-flushed after each call to one of the Print() or Warning() methods.
43  };
44 }
45 
46 #endif
This class implements the ConsoleI interface by writing the console output into a text file...
Definition: ConsoleFile.hpp:18
void Print(const std::string &s)
Print message to console.
Definition: ConsoleFile.cpp:26
void DevPrint(const std::string &s)
Print dev message to console.
Definition: ConsoleFile.cpp:33
void DevWarning(const std::string &s)
Print dev warning to console.
Definition: ConsoleFile.cpp:47
void SetAutoFlush(bool AutoFlush)
Sets if the console buffer should be auto-flushed after each call to one of the Print() or Warning() ...
Definition: ConsoleFile.hpp:27
This class is an interface to the application console.
Definition: Console.hpp:18
ConsoleFileT(const std::string &FileName)
Constructor for creating an instance of a ConsoleFileT.
Definition: ConsoleFile.cpp:13
void Warning(const std::string &s)
Print warning to console.
Definition: ConsoleFile.cpp:40
void Flush()
Flushes the buffers so that all contents is immediately written into the file.
Definition: ConsoleFile.cpp:20