RotatingFileChannel
RotatingFileChannel
#include <icy/logger.h>class RotatingFileChannelDefined in src/base/include/icy/logger.h:478
Inherits:
LogChannel
Log channel that writes to time-rotated log files.
List of all members
| Name | Kind | Owner |
|---|---|---|
RotatingFileChannel | function | Declared here |
~RotatingFileChannel | function | Declared here |
write | function | Declared here |
rotate | function | Declared here |
dir | function | Declared here |
filename | function | Declared here |
rotationInterval | function | Declared here |
setDir | function | Declared here |
setExtension | function | Declared here |
setRotationInterval | function | Declared here |
_fstream | variable | Declared here |
_dir | variable | Declared here |
_filename | variable | Declared here |
_extension | variable | Declared here |
_rotationInterval | variable | Declared here |
_rotatedAt | variable | Declared here |
LogChannel | function | Inherited from LogChannel |
~LogChannel | function | Inherited from LogChannel |
write | function | Inherited from LogChannel |
write | function | Inherited from LogChannel |
format | function | Inherited from LogChannel |
name | function | Inherited from LogChannel |
level | function | Inherited from LogChannel |
timeFormat | function | Inherited from LogChannel |
setLevel | function | Inherited from LogChannel |
setTimeFormat | function | Inherited from LogChannel |
setFilter | function | Inherited from LogChannel |
_name | variable | Inherited from LogChannel |
_level | variable | Inherited from LogChannel |
_timeFormat | variable | Inherited from LogChannel |
_filter | variable | Inherited from LogChannel |
Inherited from LogChannel
| Kind | Name | Description |
|---|---|---|
function | LogChannel | |
function | ~LogChannel virtual | Defaulted destructor. |
function | write virtual | Writes a log stream entry to this channel. |
function | write virtual | Writes a plain message to this channel. |
function | format virtual | Formats a log stream entry into the given output stream. |
function | name const inline | Returns the channel name. |
function | level const inline | Returns the minimum severity level. |
function | timeFormat const inline | Returns the timestamp format string. |
function | setLevel inline | Sets the minimum severity level. |
function | setTimeFormat inline | Sets the timestamp format string. |
function | setFilter inline | Sets a realm filter; only messages whose realm matches are written. |
variable | _name | |
variable | _level | |
variable | _timeFormat | |
variable | _filter |
Public Methods
| Return | Name | Description |
|---|---|---|
RotatingFileChannel | ||
void | write virtual override | 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
RotatingFileChannel(std::string name, std::string dir, Level level = Level::Debug, std::string extension = "log", int rotationInterval = 12 *3600, std::string timeFormat = "%H:%M:%S")Defined in src/base/include/icy/logger.h:487
Parameters
nameUnique channel name.dirDirectory in which rotated log files are written.levelMinimum severity level; messages below this level are dropped.extensionFile extension for log files (without leading dot).rotationIntervalSeconds between log rotations (default: 12 hours).timeFormatstrftime-compatible format string for timestamps.
write
virtual override
virtual void write(const LogStream & stream) overrideDefined in src/base/include/icy/logger.h:498
Formats and writes the log stream entry to the current log file. Rotates the file if the rotation interval has elapsed.
Parameters
streamThe log stream to write.
Reimplements
rotate
virtual
virtual void rotate()Defined in src/base/include/icy/logger.h:501
Closes the current log file and opens a new one with a timestamped filename.
dir
const inline
inline std::string dir() constDefined in src/base/include/icy/logger.h:504
Returns the directory where log files are written.
filename
const inline
inline std::string filename() constDefined in src/base/include/icy/logger.h:507
Returns the filename of the currently open log file.
rotationInterval
const inline
inline int rotationInterval() constDefined in src/base/include/icy/logger.h:510
Returns the rotation interval in seconds.
setDir
inline
inline void setDir(std::string dir)Defined in src/base/include/icy/logger.h:514
Sets the output directory for rotated log files.
Parameters
dirTarget directory path.
setExtension
inline
inline void setExtension(std::string ext)Defined in src/base/include/icy/logger.h:518
Sets the file extension for rotated log files.
Parameters
extExtension without leading dot (e.g. "log").
setRotationInterval
inline
inline void setRotationInterval(int interval)Defined in src/base/include/icy/logger.h:522
Sets the rotation interval.
Parameters
intervalNumber of seconds between rotations.
Protected Attributes
| 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. |
_fstream
std::unique_ptr< std::ofstream > _fstreamDefined in src/base/include/icy/logger.h:525
_dir
std::string _dirDefined in src/base/include/icy/logger.h:526
_filename
std::string _filenameDefined in src/base/include/icy/logger.h:527
_extension
std::string _extensionDefined in src/base/include/icy/logger.h:528
_rotationInterval
int _rotationIntervalDefined in src/base/include/icy/logger.h:529
The log rotation interval in seconds.
_rotatedAt
time_t _rotatedAtDefined in src/base/include/icy/logger.h:530
The time the log was last rotated.
