NexusForce
1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
file_sink.hpp
浏览该文件的文档.
1
#ifndef NEFORCE_LOGGING_FILE_SINK_HPP__
2
#define NEFORCE_LOGGING_FILE_SINK_HPP__
3
14
15
#include "
NeForce/core/async/mutex.hpp
"
16
#include "
NeForce/core/file/file.hpp
"
17
#include "
NeForce/logging/log_sink.hpp
"
18
NEFORCE_BEGIN_NAMESPACE__
19
24
32
class
NEFORCE_API
file_sink
final :
public
log_sink
{
33
private
:
34
file
file_;
35
mutex
mutex_;
36
path
base_filename_;
37
string
current_date_;
38
size_t
max_file_size_;
39
size_t
current_size_;
40
int
file_index_;
41
bool
enable_date_rotation_;
42
size_t
max_files_;
43
44
void
open_new_file();
45
void
cleanup_old_files();
46
47
void
rotate_file();
48
void
rotate_by_date(
string
today);
49
50
public
:
58
explicit
file_sink
(
path
filename,
size_t
max_file_size =
static_cast<
size_t
>
(10 * 1024 * 1024),
59
bool
enable_date_rotation =
true
,
size_t
max_files = 0);
60
67
void
log
(
const
log_event
& event)
override
;
68
70
void
flush
()
override
;
71
};
72
// Logging
74
75
NEFORCE_END_NAMESPACE__
76
#endif
// NEFORCE_LOGGING_FILE_SINK_HPP__
neforce::file_sink::flush
void flush() override
刷新文件缓冲区到磁盘
neforce::file_sink::log
void log(const log_event &event) override
输出日志到文件
neforce::file_sink::file_sink
file_sink(path filename, size_t max_file_size=static_cast< size_t >(10 *1024 *1024), bool enable_date_rotation=true, size_t max_files=0)
构造文件输出目标
neforce::file
文件操作类
定义
file.hpp:43
neforce::log_sink
日志输出目标基类
定义
log_sink.hpp:47
neforce::mutex
非递归互斥锁
定义
mutex.hpp:45
neforce::path
文件路径类
定义
path.hpp:36
file.hpp
文件操作类
log_sink.hpp
日志输出目标
mutex.hpp
互斥锁
neforce::log_event
日志事件结构体
定义
log_event.hpp:173
include
NeForce
logging
file_sink.hpp
制作者
1.16.0