gramods
Loading...
Searching...
No Matches
OStreamMessageSink.hh
1
2#ifndef GRAMODS_CORE_OSTREAMMESSAGESINK
3#define GRAMODS_CORE_OSTREAMMESSAGESINK
4
5#include <gmCore/MessageSink.hh>
6
7#include <mutex>
8
9BEGIN_NAMESPACE_GMCORE;
10
14 : public MessageSink {
15
16public:
17
23 void setStream(std::ostream *s) {
24 std::lock_guard<std::mutex> guard(lock);
25 raw_out = s;
26 shared_out = nullptr;
27 }
28
35 void setStream(std::shared_ptr<std::ostream> s) {
36 std::lock_guard<std::mutex> guard(lock);
37 raw_out = nullptr;
38 shared_out = s;
39 }
40
47 void setStream(std::string name);
48
55 void setUseAnsiColor(bool on);
56
57 void output(Message msg);
58
65 void setLevel(int l) { level = l; }
66
67 GM_OFI_DECLARE;
68
69private:
70
71 std::ostream *raw_out = nullptr;
72 std::shared_ptr<std::ostream> shared_out;
73 std::mutex lock;
74
75 bool use_ansi_color = false;
76 int level = 2;
77};
78
79END_NAMESPACE_GMCORE;
80
81#endif
This is the base type for back-ends taking care of information sent to the Console class.
Definition MessageSink.hh:23
Definition OStreamMessageSink.hh:14
void setLevel(int l)
Set the level of messages to output.
Definition OStreamMessageSink.hh:65
void setStream(std::ostream *s)
Set the stream to use as output.
Definition OStreamMessageSink.hh:23
void setStream(std::shared_ptr< std::ostream > s)
Set the stream to use as output.
Definition OStreamMessageSink.hh:35