qxLib
file_logger_stream_fopen.h
Go to the documentation of this file.
1 /**
2 
3  @file file_logger_stream_fopen.h
4  @author Khrapov
5  @date 14.01.2026
6  @copyright © Nick Khrapov, 2026. All right reserved.
7 
8 **/
9 #pragma once
10 
12 #include <qx/math/units/data.h>
13 
14 #include <cstdio>
15 
16 namespace qx
17 {
18 
19 /**
20 
21  @class file_logger_stream_fopen
22  @brief FILE* based file logger stream
23  @details UTF-8 LE (char) or UTF-16 LE (wchar_t)
24  @author Khrapov
25  @date 15.01.2026
26 
27 **/
29 {
30 public:
31  /**
32  @brief file_logger_stream_fopen object constructor
33  @param streamConfig - File logger configuration
34  @param bufferSize - Outer buffer size for a FILE. if 0, the default buffer is used
35  The buffer size determines how often data will be flushed.
36  The default value of 8192 chars corresponds to ~30-50 lines of logs.
37  **/
39  const config& streamConfig = config(),
40  unit<size_t, units::data> bufferSize = { 8192 * sizeof(char_type), units::data::bytes }) noexcept;
42 
43  virtual ~file_logger_stream_fopen() override;
44 
45  // base_logger_stream
46  //
47  virtual void do_log(const category& category, verbosity eVerbosity, string_view svMessage) override;
48  virtual void do_flush() override;
49 
50 private:
51  std::vector<char> m_Buffer;
52  FILE* m_pFile = nullptr;
53 };
54 
55 } // namespace qx
56 
Base class for all file logger streams.
A category is a class that identifies a particular piece of code. This code can be located in differe...
Definition: category.h:59
FILE* based file logger stream.
virtual void do_log(const category &category, verbosity eVerbosity, string_view svMessage) override
Proceed stream logging.
virtual void do_flush() override
Flush the stream.
file_logger_stream_fopen(const config &streamConfig=config(), unit< size_t, units::data > bufferSize={ 8192 *sizeof(char_type), units::data::bytes }) noexcept
file_logger_stream_fopen object constructor
Definition: base.h:52