|
unilink
0.4.3
A simple C++ library for unified async communication
|
Log rotation manager. More...
#include <log_rotation.hpp>
Public Member Functions | |
| LogRotation (const LogRotationConfig &config=LogRotationConfig{}) | |
| Constructor. More... | |
| bool | should_rotate (const std::string &filepath) const |
| Check if current log file needs rotation. More... | |
| std::string | rotate (const std::string &filepath) |
| Perform log rotation. More... | |
| void | cleanup_old_files (const std::string &base_filepath) |
| Clean up old log files. More... | |
| std::string | get_next_file_path (const std::string &base_filepath) const |
| Get next available log file path. More... | |
| void | update_config (const LogRotationConfig &config) |
| Update rotation configuration. More... | |
| const LogRotationConfig & | get_config () const |
| Get current configuration. More... | |
Static Public Member Functions | |
| static size_t | get_file_size (const std::string &filepath) |
| Get file size in bytes. More... | |
| static std::vector< std::string > | get_log_files (const std::string &base_filepath) |
| Get all log files matching pattern. More... | |
Log rotation manager.
Handles log file rotation based on size and automatic cleanup of old log files based on count limits.
Definition at line 51 of file log_rotation.hpp.
|
explicit |
| void unilink::diagnostics::LogRotation::cleanup_old_files | ( | const std::string & | base_filepath | ) |
Clean up old log files.
| base_filepath | Base log file path (without index) |
Definition at line 64 of file log_rotation.cc.
|
inline |
Get current configuration.
Definition at line 95 of file log_rotation.hpp.
|
static |
Get file size in bytes.
| filepath | File path to check |
Definition at line 114 of file log_rotation.cc.
|
static |
Get all log files matching pattern.
| base_filepath | Base log file path |
Definition at line 125 of file log_rotation.cc.
| std::string unilink::diagnostics::LogRotation::get_next_file_path | ( | const std::string & | base_filepath | ) | const |
Get next available log file path.
| base_filepath | Base log file path |
Definition at line 86 of file log_rotation.cc.
| std::string unilink::diagnostics::LogRotation::rotate | ( | const std::string & | filepath | ) |
Perform log rotation.
| filepath | Current log file path |
Definition at line 40 of file log_rotation.cc.
| bool unilink::diagnostics::LogRotation::should_rotate | ( | const std::string & | filepath | ) | const |
Check if current log file needs rotation.
| filepath | Current log file path |
Definition at line 29 of file log_rotation.cc.
| void unilink::diagnostics::LogRotation::update_config | ( | const LogRotationConfig & | config | ) |
Update rotation configuration.
| config | New configuration |
Definition at line 109 of file log_rotation.cc.