Joedb 10.3.2
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Stream_Logger.cpp
Go to the documentation of this file.
3
4#include <iostream>
5
6namespace joedb
7{
8 ////////////////////////////////////////////////////////////////////////////
9 Stream_Logger::Stream_Logger(std::ostream &out, std::string tag):
10 out(out),
11 tag(std::move(tag))
12 {
13 }
14
15 ////////////////////////////////////////////////////////////////////////////
16 void Stream_Logger::log(const std::string &message) noexcept
17 {
18 try
19 {
20 std::unique_lock lock(mutex);
21 out << joedb::get_time_string_of_now() << ' ';
22 if (!tag.empty())
23 out << tag << ": ";
24 out << message << '\n';
25 out.flush();
26 }
27 catch (...)
28 {
29 }
30 }
31}
void log(const std::string &message) noexcept override
Stream_Logger(std::ostream &out, std::string tag="")
std::string get_time_string_of_now()