qxLib
file_logger_stream.h
Go to the documentation of this file.
1 /**
2 
3  @file file_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 
12 
13 #include <filesystem>
14 #include <fstream>
15 
16 namespace qx
17 {
18 
19 enum class log_file_policy
20 {
21  append, //!< append all
22  clear_then_uppend, //!< clear file at start, then append
23  time_name, //!< create new file with time name
24 };
25 
26 /**
27 
28  @class file_logger_stream
29  @brief Logger stream for file output
30  @details ~
31  @author Khrapov
32  @date 28.07.2021
33 
34 **/
36 {
37 public:
38  /**
39  @brief file_logger_stream object constructor
40  @param bAlwaysFlush - true if need to flush after every output, decreases performance
41  @param eLogFilePolicy - policy to use
42  @param svFileName - log file name
43  **/
45  bool bAlwaysFlush = false,
46  log_file_policy eLogFilePolicy = log_file_policy::append,
47  string_view svFileName = L"application");
48 
49  virtual ~file_logger_stream() override;
50 
51  // base_logger_stream
52  //
53  virtual void flush() override;
54  virtual void do_log(
55  string_view svMessage,
56  const log_unit& logUnit,
57  const std::vector<logger_color_range>& colors,
58  verbosity eVerbosity) override;
59 
60 private:
61  std::wofstream m_File;
62 };
63 
64 } // namespace qx
65 
Base class for logger streams.
Logger stream for file output.
virtual void do_log(string_view svMessage, const log_unit &logUnit, const std::vector< logger_color_range > &colors, verbosity eVerbosity) override
Proceed stream logging.
virtual void flush() override
Flush stream.
file_logger_stream(bool bAlwaysFlush=false, log_file_policy eLogFilePolicy=log_file_policy::append, string_view svFileName=L"application")
file_logger_stream object constructor
@ clear_then_uppend
clear file at start, then append
@ time_name
create new file with time name
@ append
append all