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 {
29 
30 public:
32  {
33  // Optimization: Don't synchronize to the standard C streams after each input/output operation.
34  // Be careful, as it changes the global setting. You'll need to revert it manually if needed.
35  bool bDisableStdioSync = false;
36 
37  // Optimization: Untie cin from cout.
38  // Tied streams ensure that one stream is flushed automatically before each I/O operation on the other stream.
39  // Be careful, as it changes the global setting. You'll need to revert it manually if needed.
40  bool bUntieCin = false;
41  };
42 
43 public:
44  /**
45  @brief cout_logger_stream object constructor
46  @param optStreamConfig - logger stream configuration
47  **/
48  cout_logger_stream(std::optional<config> optStreamConfig = {}) noexcept;
49 
50  cout_logger_stream(cout_logger_stream&&) noexcept = default;
51 
52 
53  // base_logger_stream
54  //
55  virtual void do_flush() override;
56 
57 private:
58  // base_standard_streams_stream
59  //
60  virtual void cout_colorized(verbosity eVerbosity, string_view svMessage, const color& rangeColor) override;
61  virtual void cout_common(verbosity eVerbosity, string_view svMessage) override;
62 };
63 
64 } // namespace qx
65 
66 #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.