qxLib
cout_logger_stream.h
Go to the documentation of this file.
1 /**
2 
3  @file cout_logger_stream.h
4  @author Khrapov
5  @date 28.07.2021
6  @copyright © Nick Khrapov, 2021. All right reserved.
7 
8 **/
9 #pragma once
10 
13 
14 namespace qx
15 {
16 
17 /**
18 
19  @class cout_logger_stream
20  @brief Logger stream based on std::cout output
21  @details On Linux, output is always `UTF8` (aka char) even with qx::char_type == wchar_t.
22  @author Khrapov
23  @date 28.07.2021
24 
25 **/
27 {
28 public:
30  {
31  // Optimization: Don't synchronize to the standard C streams after each input/output operation.
32  // Be careful, as it changes the global setting. You'll need to revert it manually if needed.
33  bool bDisableStdioSync = false;
34 
35  // Optimization: Untie cin from cout.
36  // Tied streams ensure that one stream is flushed automatically before each I/O operation on the other stream.
37  // Be careful, as it changes the global setting. You'll need to revert it manually if needed.
38  bool bUntieCin = false;
39  };
40 
41 public:
42  /**
43  @brief cout_logger_stream object constructor
44  @param optStreamConfig - logger stream configuration
45  **/
46  cout_logger_stream(std::optional<config> optStreamConfig = {}) noexcept;
47 
48  cout_logger_stream(cout_logger_stream&&) noexcept = default;
49 
50 
51  // base_logger_stream
52  //
53  virtual void do_flush() override;
54 
55 private:
56  // base_standard_streams_stream
57  //
58  virtual void cout_colorized(verbosity eVerbosity, string_view svMessage, const color& rangeColor) override;
59  virtual void cout_common(verbosity eVerbosity, string_view svMessage) override;
60 };
61 
62 } // namespace qx
63 
64 #include <qx/logger/cout_logger_stream.inl>
A base class for logger streams based on standard streams.
RGBA color.
Definition: color.h:193
Logger stream based on std::cout output.
cout_logger_stream(std::optional< config > optStreamConfig={}) noexcept
cout_logger_stream object constructor
virtual void do_flush() override
Flush the stream.