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 {
31 
32 public:
33  /**
34  @brief file_logger_stream_fopen object constructor
35  @param streamConfig - File logger configuration
36  @param bufferSize - Outer buffer size for a FILE. if 0, the default buffer is used
37  The buffer size determines how often data will be flushed.
38  The default value of 8192 chars corresponds to ~30-50 lines of logs.
39  **/
41  const config& streamConfig = config(),
42  unit<size_t, units::data> bufferSize = { 8192 * sizeof(char_type), units::data::bytes }) noexcept;
44 
45  virtual ~file_logger_stream_fopen() override;
46 
47  // base_logger_stream
48  //
49  virtual void do_log(
50  const category& category,
51  verbosity eVerbosity,
52  std::thread::id threadId,
53  std::chrono::system_clock::time_point messageTime,
54  string_view svFile,
55  string_view svFunction,
56  int nLine,
57  string_view svMessage) override;
58  virtual void do_flush() override;
59 
60 private:
61  std::vector<char> m_Buffer;
62  FILE* m_pFile = nullptr;
63 };
64 
65 } // namespace qx
66 
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_flush() override
Flush the stream.
virtual void do_log(const category &category, verbosity eVerbosity, std::thread::id threadId, std::chrono::system_clock::time_point messageTime, string_view svFile, string_view svFunction, int nLine, string_view svMessage) override
Proceed stream logging.
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