MyGUI  3.0.1
MyGUI_LogStream.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_LOG_STREAM_H__
24 #define __MYGUI_LOG_STREAM_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include <fstream>
28 #include <iostream>
29 #include <string>
30 
31 namespace MyGUI
32 {
33 
35  {
36  friend class LogManager;
37 
38  public:
39  struct LogStreamEnd { };
40 
41  public:
42  LogStream& operator<<(const LogStreamEnd& _endl);
43 
44  template <typename T>
45  inline LogStream& operator<<(T _value)
46  {
47  if (getSTDOutputEnabled()) std::cout << _value;
48  if (mStream.is_open()) mStream << _value;
49  return *this;
50  }
51 
52  const std::string& getFileName() const { return mFileName; }
53 
54  private:
55  LogStream();
56  ~LogStream();
57 
58  LogStream(const std::string& _file);
59 
60  void start(const std::string& _section, const std::string& _level);
61 
62  bool getSTDOutputEnabled();
63 
64  void lock() const { }
65  void release() const { }
66 
67  private:
68  std::ofstream mStream;
69  std::string mFileName;
70  };
71 
72 } // namespace MyGUI
73 
74 #endif // __MYGUI_LOG_STREAM_H__