#include <icy/logger.h>Inherits:
LogChannel
Log channel that writes to time-rotated log files.
| Return | Name | Description |
|---|---|---|
RotatingFileChannel | #### Parameters | |
void | write virtual | Formats and writes the log stream entry to the current log file. Rotates the file if the rotation interval has elapsed. |
void | rotate virtual | Closes the current log file and opens a new one with a timestamped filename. |
std::string | dir const inline | Returns the directory where log files are written. |
std::string | filename const inline | Returns the filename of the currently open log file. |
int | rotationInterval const inline | Returns the rotation interval in seconds. |
void | setDir inline | Sets the output directory for rotated log files. |
void | setExtension inline | Sets the file extension for rotated log files. |
void | setRotationInterval inline | Sets the rotation interval. |
RotatingFileChannel(std::string name, std::string dir, Level level, std::string extension, int rotationInterval, std::string timeFormat)name Unique channel name.
dir Directory in which rotated log files are written.
level Minimum severity level; messages below this level are dropped.
extension File extension for log files (without leading dot).
rotationInterval Seconds between log rotations (default: 12 hours).
timeFormat strftime-compatible format string for timestamps.
virtual
virtual void write(const LogStream & stream)Formats and writes the log stream entry to the current log file. Rotates the file if the rotation interval has elapsed.
stream The log stream to write.virtual
virtual void rotate()Closes the current log file and opens a new one with a timestamped filename.
const inline
inline std::string dir() constReturns the directory where log files are written.
const inline
inline std::string filename() constReturns the filename of the currently open log file.
const inline
inline int rotationInterval() constReturns the rotation interval in seconds.
inline
inline void setDir(std::string dir)Sets the output directory for rotated log files.
dir Target directory path.inline
inline void setExtension(std::string ext)Sets the file extension for rotated log files.
ext Extension without leading dot (e.g. "log").inline
inline void setRotationInterval(int interval)Sets the rotation interval.
interval Number of seconds between rotations.| Return | Name | Description |
|---|---|---|
std::unique_ptr< std::ofstream > | _fstream | |
std::string | _dir | |
std::string | _filename | |
std::string | _extension | |
int | _rotationInterval | The log rotation interval in seconds. |
time_t | _rotatedAt | The time the log was last rotated. |
std::unique_ptr< std::ofstream > _fstreamstd::string _dirstd::string _filenamestd::string _extensionint _rotationIntervalThe log rotation interval in seconds.
time_t _rotatedAtThe time the log was last rotated.