Base module
FileChannel
Log channel that writes formatted messages to a file.
FileChannel
#include <icy/logger.h>Inherits:
LogChannel
Log channel that writes formatted messages to a file.
Public Methods
| Return | Name | Description |
|---|---|---|
FileChannel | #### Parameters | |
void | write virtual | Formats and writes the log stream entry to the file. Opens the file on first write if not already open. |
void | setPath | Sets the file path and reopens the file stream. |
std::string | path const | Returns the current log file path. |
FileChannel
FileChannel(std::string name, std::string path, Level level, std::string timeFormat)Parameters
nameUnique channel name.pathPath to the output log file. Directories are created if needed.levelMinimum severity level; messages below this level are dropped.timeFormatstrftime-compatible format string for timestamps.
write
virtual
virtual void write(const LogStream & stream)Formats and writes the log stream entry to the file. Opens the file on first write if not already open.
Parameters
streamThe log stream to write.
setPath
void setPath(const std::string & path)Sets the file path and reopens the file stream.
Parameters
pathPath to the new log file.
path
const
std::string path() constReturns the current log file path.
Returns
Absolute or relative path to the log file.
Protected Attributes
_fstream
std::ofstream _fstream_path
std::string _pathProtected Methods
open
virtual
virtual void open()close
virtual
virtual void close()