RotatingFileChannel
#include <icy/logger.h>
class RotatingFileChannelDefined in src/base/include/icy/logger.h:520
- Inherits
LogChannel
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 | ||
~RotatingFileChannel virtual | ||
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:529
Parameters
| Parameter | Type | Description |
|---|---|---|
name | std::string | Unique channel name. |
dir | std::string | Directory in which rotated log files are written. |
level | Level | Minimum severity level; messages below this level are dropped. |
extension | std::string | File extension for log files (without leading dot). |
rotationInterval | int | Seconds between log rotations (default: 12 hours). |
timeFormat | std::string | strftime-compatible format string for timestamps. |
~RotatingFileChannel
virtual
virtual ~RotatingFileChannel()Defined in src/base/include/icy/logger.h:535
write
virtual override
virtual void write(const LogStream & stream) overrideDefined in src/base/include/icy/logger.h:540
Formats and writes the log stream entry to the current log file. Rotates the file if the rotation interval has elapsed.
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
stream | const LogStream & | The log stream to write. |
rotate
virtual
virtual void rotate()Defined in src/base/include/icy/logger.h:543
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:546
Returns the directory where log files are written.
filename
const inline
inline std::string filename() constDefined in src/base/include/icy/logger.h:549
Returns the filename of the currently open log file.
rotationInterval
const inline
inline int rotationInterval() constDefined in src/base/include/icy/logger.h:552
Returns the rotation interval in seconds.
setDir
inline
inline void setDir(std::string dir)Defined in src/base/include/icy/logger.h:556
Sets the output directory for rotated log files.
Parameters
| Parameter | Type | Description |
|---|---|---|
dir | std::string | Target directory path. |
setExtension
inline
inline void setExtension(std::string ext)Defined in src/base/include/icy/logger.h:560
Sets the file extension for rotated log files.
Parameters
| Parameter | Type | Description |
|---|---|---|
ext | std::string | Extension without leading dot (e.g. "log"). |
setRotationInterval
inline
inline void setRotationInterval(int interval)Defined in src/base/include/icy/logger.h:564
Sets the rotation interval.
Parameters
| Parameter | Type | Description |
|---|---|---|
interval | int | Number 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:567
_dir
std::string _dirDefined in src/base/include/icy/logger.h:568
_filename
std::string _filenameDefined in src/base/include/icy/logger.h:569
_extension
std::string _extensionDefined in src/base/include/icy/logger.h:570
_rotationInterval
int _rotationIntervalDefined in src/base/include/icy/logger.h:571
The log rotation interval in seconds.
_rotatedAt
time_t _rotatedAtDefined in src/base/include/icy/logger.h:572
The time the log was last rotated.
