gramods
Loading...
Searching...
No Matches
LogFileMessageSink.hh
1
2#ifndef GRAMODS_CORE_LOGFILEMESSAGESINK
3#define GRAMODS_CORE_LOGFILEMESSAGESINK
4
5#include <gmCore/MessageSink.hh>
6
7#include <mutex>
8#include <fstream>
9
10BEGIN_NAMESPACE_GMCORE;
11
15class LogFileMessageSink
16 : public MessageSink {
17
18public:
19
20 LogFileMessageSink();
21
27 void setLogFilePath(std::filesystem::path path);
28
36 void setAppend(bool on);
37
44 void setLevel(int l) { level = l; }
45
46 void output(Message msg);
47
48 GM_OFI_DECLARE;
49
50private:
51
52 bool append;
53 std::filesystem::path logfile_path;
54 std::ofstream logfile;
55 int level = 2;
56
57 std::mutex lock;
58};
59
60END_NAMESPACE_GMCORE;
61
62#endif
void setAppend(bool on)
Set to true if the messages should be appended to the end of the file, if it already exists.
Definition LogFileMessageSink.cpp:24
void setLogFilePath(std::filesystem::path path)
Sets the path to the log file to write to.
Definition LogFileMessageSink.cpp:17
void setLevel(int l)
Set the level of messages to output.
Definition LogFileMessageSink.hh:44
This is the base type for back-ends taking care of information sent to the Console class.
Definition MessageSink.hh:23