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 #include <iostream>
15 
16 namespace qx
17 {
18 
19 /**
20 
21  @class cout_logger_stream
22  @brief Logger stream for std::cout output
23  @author Khrapov
24  @date 28.07.2021
25 
26 **/
28 {
29 public:
30  /**
31  @brief cout_logger_stream object constructor
32  @param bAlwaysFlush - true if need to flush after every output, decreases performance
33  @param bUseColors - use color when output is not info
34  @param bDisableStdioSync - don't synchronize to the standard C streams after each input/output operation
35  @param bUntieCin - untie cin from cout
36  **/
38  bool bAlwaysFlush = false,
39  bool bUseColors = true,
40  bool bDisableStdioSync = true,
41  bool bUntieCin = true);
42 
43  // base_logger_stream
44  //
45  virtual void flush() override;
46  virtual void do_log(
47  string_view svMessage,
48  const log_unit& logUnit,
49  const std::vector<logger_color_range>& colors,
50  verbosity eVerbosity) override;
51 
52  /**
53  @brief Set whether cout output should be colored
54  @param bUsingColors - true if cout output should be colored
55  **/
56  void set_using_colors(bool bUsingColors) noexcept;
57 
58 private:
59  bool m_bUsingColors = true;
60 };
61 
62 } // namespace qx
63 
Base class for logger streams.
Logger stream for std::cout output.
virtual void flush() override
Flush stream.
cout_logger_stream(bool bAlwaysFlush=false, bool bUseColors=true, bool bDisableStdioSync=true, bool bUntieCin=true)
cout_logger_stream object constructor
virtual void do_log(string_view svMessage, const log_unit &logUnit, const std::vector< logger_color_range > &colors, verbosity eVerbosity) override
Proceed stream logging.
void set_using_colors(bool bUsingColors) noexcept
Set whether cout output should be colored.