FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTlogger.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifndef FMTlogger_H_INCLUDED
9#define FMTlogger_H_INCLUDED
10#include <boost/serialization/export.hpp>
11#include <boost/thread/recursive_mutex.hpp>
12#include <fstream>
13#include <string>
14#include "FMTexception.hpp"
15
16namespace boost
17{
18 namespace serialization
19 {
20 class access;
21 }
22}
23
24
26namespace Logging
27{
28 class FMTsolverlogger;
29 //class CoinMessageHandler;
30 // DocString: FMTlogger
37 {
38 friend class boost::serialization::access;
39 // DocString: FMTlogger::save
43 template<class Archive>
44 void save(Archive& ar, const unsigned int version) const;
45 // DocString: FMTlogger::load
49 template<class Archive>
50 void load(Archive& ar, const unsigned int version);
51 // DocString: FMTlogger::serialize
55 template<class Archive>
56 void serialize(Archive &ar, const unsigned int file_version);
57 // DocString: FMTlogger::settofile
61 void settofile(const std::string& filename) const;
62 protected:
63 #if defined FMTWITHOSI
64 std::unique_ptr<FMTsolverlogger>solverref;
65 #endif
66 // DocString: FMTlogger::pathtostream
68 std::string filepath;
69 // DocString: FMTlogger::filestream
71 mutable std::ofstream* filestream;
72 // DocString: FMTlogger::mtx
74 //mutable std::recursive_mutex mtx;
75 mutable boost::recursive_mutex mtx;
76 // DocString: FMTlogger::flushstream
79 // DocString: FMTlogger::cout
84 virtual void cout(const char* message) const;
85 #ifdef FMTWITHOSI
86 // DocString: FMTlogger::setlogginglevel
90 virtual void setlogginglevel(const int& level);
91 #endif // FMTWITHOSI
92 public:
93 // DocString: FMTlogger()
98 // DocString: ~FMTlogger()
102 virtual ~FMTlogger();
103 // DocString: FMTlogger(const FMTlogger&)
107 FMTlogger(const FMTlogger& rhs);
108 // DocString: FMTlogger::redirectofile
112 void redirectofile(const std::string& filename);
113 // DocString: FMTlogger::closefilestream
118 // DocString: FMTlogger::operator=
122 FMTlogger& operator = (const FMTlogger& rhs);
123 #ifdef FMTWITHOSI
124 // DocString: FMTlogger::print
129 virtual int print();
130 // DocString: FMTlogger::checkSeverity
134 virtual void checkSeverity();
135 // DocString: FMTlogger::clone
139 virtual FMTlogger* clone() const;
140 #endif
141 // DocString: FMTlogger::getlogstamp
145 virtual std::string getlogstamp() const;
146 // DocString: FMTlogger::logstamp
150 virtual void logstamp();
151 // DocString: FMTlogger::logtime
155 virtual void logtime();
156 // DocString: FMTlogger::setstreamflush
160 void setstreamflush(bool flush);
161 // DocString: FMTlogger::operator<<(const std::string& msg)
165 virtual FMTlogger& operator<<(const std::string& msg);
166 // DocString: FMTlogger::operator<<(const int& msg)
170 virtual FMTlogger& operator<<(const int& msg);
171 // DocString: FMTlogger::operator<<(const double& msg)
175 virtual FMTlogger& operator<<(const double& msg);
176 // DocString: FMTlogger::operator<<(const float& msg)
180 virtual FMTlogger& operator<<(const float& msg);
181 // DocString: FMTlogger::operator<<(const std::time_t& msg)
185 virtual FMTlogger& operator<<(const std::time_t& msg);
186 // DocString: FMTlogger::operator<<(const size_t& msg)
190 virtual FMTlogger& operator<<(const size_t& msg);
191 // DocString: FMTlogger::operator<<(const unsigned int& msg)
195 virtual FMTlogger& operator<<(const unsigned int& msg);
196 // DocString: FMTlogger::logwithlevel
201 virtual bool logwithlevel(const std::string &msg, const int& messagelevel) const;
202 #ifdef FMTWITHOSI
203 // DocString: FMTlogger::getsolverlogger
208 #endif
209
210 };
211
212}
213
214BOOST_CLASS_EXPORT_KEY(Logging::FMTlogger)
215
216#endif
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTlogger.hpp:37
virtual FMTlogger & operator<<(const std::time_t &msg)
virtual int print()
bool flushstream
If true will flush stream at each write.
Definition: FMTlogger.hpp:78
std::string filepath
string path the the potential filestream
Definition: FMTlogger.hpp:68
virtual void logstamp()
virtual FMTlogger & operator<<(const float &msg)
virtual ~FMTlogger()
virtual FMTlogger & operator<<(const size_t &msg)
virtual FMTlogger & operator<<(const std::string &msg)
virtual void cout(const char *message) const
virtual bool logwithlevel(const std::string &msg, const int &messagelevel) const
virtual void setlogginglevel(const int &level)
std::unique_ptr< FMTsolverlogger > solverref
Definition: FMTlogger.hpp:64
void setstreamflush(bool flush)
virtual FMTsolverlogger * getsolverlogger()
virtual FMTlogger * clone() const
void redirectofile(const std::string &filename)
virtual FMTlogger & operator<<(const unsigned int &msg)
FMTlogger(const FMTlogger &rhs)
virtual void logtime()
virtual void checkSeverity()
std::ofstream * filestream
stream if the logger redirect the logging into somesort of file.
Definition: FMTlogger.hpp:71
virtual FMTlogger & operator<<(const double &msg)
boost::recursive_mutex mtx
Mutex for multi-threading.
Definition: FMTlogger.hpp:75
virtual FMTlogger & operator<<(const int &msg)
virtual std::string getlogstamp() const
Definition: FMTsolverlogger.hpp:25
Namespace for the log management, provides different log handlers.
Definition: FMTdebuglogger.hpp:14
Definition: FMTaction.hpp:364