Documentation for OpenFLUID 2.2.0
InternalLogger.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file InternalLogger.hpp
35 
36  @author Armel THÖNI <armel.thoni@inrae.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_UTILS_INTERNALLOGGER_HPP__
41 #define __OPENFLUID_UTILS_INTERNALLOGGER_HPP__
42 
43 
44 #include <iostream>
45 
46 #include <string>
47 #include <ctime>
48 
50 #include <openfluid/config.hpp>
52 
54 
55 
56 namespace openfluid { namespace utils {
57 
58 
60 {
62 
63  private:
64 
65  bool m_Activated;
66 
67  bool m_AsFile;
68 
70 
71  std::vector<std::string> m_Logs; // only used when output as file set to false
72 
73  std::string m_LogPath;
74 
75  LoggingSystem();
76 
77  ~LoggingSystem();
78 
79 
80  public:
81 
82  void setup(bool DefaultAsFallback=true, std::string LogPath="", bool Verbose=false);
83 
84  void close();
85 
86  void add(openfluid::tools::FileLogger::LogType LType, const std::string& Context, const std::string& Msg);
87 
88  bool isActivated()
89  {
90  return m_Activated;
91  }
92 
93  std::string getLogPath()
94  {
95  return m_LogPath;
96  }
97 
98  void setOutput(bool AsFile=true)
99  {
100  m_AsFile = AsFile;
101  }
102 
103  std::string getLastLog()
104  {
105  if (m_Logs.size() > 0)
106  {
107  return m_Logs.back();
108  }
109  return "";
110  }
111 
112 };
113 
114 
115 namespace log {
116 
117 void OPENFLUID_API setup(bool DefaultAsFallback=true, std::string LogPath="", bool Verbose=false);
118 
119 void OPENFLUID_API debug(const std::string& Context, const std::string& Msg);
120 
121 void OPENFLUID_API info(const std::string& Context, const std::string& Msg);
122 
123 void OPENFLUID_API warning(const std::string& Context, const std::string& Msg);
124 
125 void OPENFLUID_API error(const std::string& Context, const std::string& Msg);
126 }
127 
128 } } // namespaces
129 
130 
131 #endif /* __OPENFLUID_UTILS_INTERNALLOGGER_HPP__ */
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition: SingletonMacros.hpp:55
Definition: FileLogger.hpp:55
LogType
Definition: FileLogger.hpp:72
Definition: InternalLogger.hpp:60
std::string getLogPath()
Definition: InternalLogger.hpp:93
void setOutput(bool AsFile=true)
Definition: InternalLogger.hpp:98
bool isActivated()
Definition: InternalLogger.hpp:88
std::string getLastLog()
Definition: InternalLogger.hpp:103
void setup(bool DefaultAsFallback=true, std::string LogPath="", bool Verbose=false)
void add(openfluid::tools::FileLogger::LogType LType, const std::string &Context, const std::string &Msg)
#define OPENFLUID_API
Definition: dllexport.hpp:86
void OPENFLUID_API error(const std::string &Context, const std::string &Msg)
void OPENFLUID_API setup(bool DefaultAsFallback=true, std::string LogPath="", bool Verbose=false)
void OPENFLUID_API debug(const std::string &Context, const std::string &Msg)
void OPENFLUID_API warning(const std::string &Context, const std::string &Msg)
void OPENFLUID_API info(const std::string &Context, const std::string &Msg)
Definition: ApplicationException.hpp:47