Maze Builder Docs 8.10.23
Loading...
Searching...
No Matches
async_logger.h
1#ifndef ASYNC_LOGGER_H
2#define ASYNC_LOGGER_H
3
4#include <functional>
5#include <memory>
6#include <string_view>
7#include <utility>
8
10
11namespace mazes
12{
13
14 class async_logger final : public singleton_base<async_logger>
15 {
16 friend class singleton_base<async_logger>;
17 public:
18 using sink_type = std::function<void(std::string_view)>;
19
20 async_logger();
21 ~async_logger();
22
24 void log(std::string_view message);
25
27 void flush();
28
30 void stop() noexcept;
31
33 void set_sink(sink_type sink);
34
35 private:
36 class impl;
37 std::unique_ptr<impl> pimpl_;
38 };
39} // namespace mazes
40
41#endif // ASYNC_LOGGER_H
void stop() noexcept
Stop the logger.
void set_sink(sink_type sink)
Replace the message sink.
void flush()
Flush all pending messages.
void log(std::string_view message)
Queue a message for asynchronous logging.