qxLib
error_context_stream.inl
Go to the documentation of this file.
1 /**
2 
3  @file error_context_stream.inl
4  @author Khrapov
5  @date 10.02.2026
6  @copyright © Nick Khrapov, 2026. All right reserved.
7 
8 **/
9 
10 namespace qx
11 {
12 
13 inline error_context_stream::error_context_stream() noexcept
14  : base_logger_stream({ .bProtectLog = false, .eMinFlushVerbosity = verbosity::none })
15  , m_Data(qx::make_unique_ref<error_context_stream_data>())
16 {
17 }
18 
20  get_on_messages() noexcept
21 {
22  return m_Data->onMessages;
23 }
24 
26  get_on_error() noexcept
27 {
28  return m_Data->onError;
29 }
30 
31 inline void error_context_stream::on_error(std::thread::id errorThreadId) noexcept
32 {
33  error_context_stream_data& data = *m_Data;
34  data.disabledThreads.lock()->push_back(errorThreadId);
35  data.onError.lock()->execute(errorThreadId);
36  std::erase(*data.disabledThreads.lock(), errorThreadId);
37 }
38 
39 inline bool error_context_stream::log_unconditionally_required(
40  const category& category,
41  verbosity eVerbosity,
42  std::thread::id threadId,
43  std::chrono::system_clock::time_point messageTime,
44  string_view svFile,
45  string_view svFunction,
46  int nLine) const noexcept
47 {
48  return m_Data.get().onMessages.lock()->contains(threadId);
49 }
50 
51 inline void error_context_stream::do_log(
52  const category& category,
53  verbosity eVerbosity,
54  std::thread::id threadId,
55  std::chrono::system_clock::time_point messageTime,
56  string_view svFile,
57  string_view svFunction,
58  int nLine,
59  string_view svMessage)
60 {
61  error_context_stream_data& data = *m_Data;
62  if (!contains(*data.disabledThreads.lock(), threadId))
63  (*data.onMessages.lock())[threadId].execute(eVerbosity, svMessage);
64 }
65 
66 inline void error_context_stream::do_flush()
67 {
68 }
69 
70 } // namespace qx
A category is a class that identifies a particular piece of code. This code can be located in differe...
Definition: category.h:59
threads_shared< on_message_delegates_map_t > & get_on_messages() noexcept
Get on messages delegate.
void on_error(std::thread::id errorThreadId) noexcept
Emit error event for all listeners.
threads_shared< on_error_delegate, std::recursive_mutex > & get_on_error() noexcept
Get on error delegate.
A class that provides thread-safe access to an object, including construction and destruction.
Check that tuple type contains T.