Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Stream_Logger.h
Go to the documentation of this file.
1#ifndef joedb_Stream_Logger
2#define joedb_Stream_Logger
3
5
6#include <ostream>
7#include <mutex>
8
9namespace joedb
10{
11 /// @ingroup error
12 class Stream_Logger: public Logger
13 {
14 private:
15 std::ostream &out;
16 std::mutex mutex;
17
18 void write(std::string_view message) noexcept override
19 {
20 try
21 {
22 std::lock_guard lock(mutex);
23 out << message;
24 }
25 catch (...)
26 {
27 }
28 }
29
30 public:
31 Stream_Logger(std::ostream &out): out(out) {}
32 };
33}
34
35#endif
Stream_Logger(std::ostream &out)