Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
InternalLogger.hpp
Go to the documentation of this file.
1/*
2
3 This file is part of OpenFLUID software
4 Copyright(c) 2021-2026, INRAE
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_BASE_INTERNALLOGGER_HPP__
41#define __OPENFLUID_BASE_INTERNALLOGGER_HPP__
42
43
44#include <iostream>
45
46#include <string>
47#include <ctime>
48
50#include <openfluid/config.hpp>
52
54
55
56namespace openfluid { namespace base {
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
76
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
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
115namespace log {
116
117void OPENFLUID_API setup(bool DefaultAsFallback=true, std::string LogPath="", bool Verbose=false);
118
119void OPENFLUID_API debug(const std::string& Context, const std::string& Msg);
120
121void OPENFLUID_API info(const std::string& Context, const std::string& Msg);
122
123void OPENFLUID_API warning(const std::string& Context, const std::string& Msg);
124
125void OPENFLUID_API error(const std::string& Context, const std::string& Msg);
126
127std::string OPENFLUID_API path();
128}
129
130} } // namespaces
131
132
133#endif /* __OPENFLUID_BASE_INTERNALLOGGER_HPP__ */
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition SingletonMacros.hpp:55
Definition InternalLogger.hpp:60
bool isActivated()
Definition InternalLogger.hpp:88
void setup(bool DefaultAsFallback=true, std::string LogPath="", bool Verbose=false)
std::string getLastLog()
Definition InternalLogger.hpp:103
void add(openfluid::tools::FileLogger::LogType LType, const std::string &Context, const std::string &Msg)
void setOutput(bool AsFile=true)
Definition InternalLogger.hpp:98
std::string getLogPath()
Definition InternalLogger.hpp:93
Definition FileLogger.hpp:55
LogType
Definition FileLogger.hpp:72
#define OPENFLUID_API
Definition dllexport.hpp:86
void OPENFLUID_API setup(bool DefaultAsFallback=true, std::string LogPath="", bool Verbose=false)
void OPENFLUID_API info(const std::string &Context, const std::string &Msg)
void OPENFLUID_API error(const std::string &Context, const std::string &Msg)
std::string OPENFLUID_API path()
void OPENFLUID_API debug(const std::string &Context, const std::string &Msg)
void OPENFLUID_API warning(const std::string &Context, const std::string &Msg)
Definition ApplicationException.hpp:47