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

ReturnNameDescription
FileChannel#### Parameters
voidwrite virtualFormats and writes the log stream entry to the file. Opens the file on first write if not already open.
voidsetPathSets the file path and reopens the file stream.
std::stringpath constReturns the current log file path.

FileChannel

FileChannel(std::string name, std::string path, Level level, std::string timeFormat)

Parameters

  • name Unique channel name.

  • path Path to the output log file. Directories are created if needed.

  • level Minimum severity level; messages below this level are dropped.

  • timeFormat strftime-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

  • stream The log stream to write.

setPath

void setPath(const std::string & path)

Sets the file path and reopens the file stream.

Parameters

  • path Path to the new log file.

path

const

std::string path() const

Returns the current log file path.

Returns

Absolute or relative path to the log file.

Protected Attributes

ReturnNameDescription
std::ofstream_fstream
std::string_path

_fstream

std::ofstream _fstream

_path

std::string _path

Protected Methods

ReturnNameDescription
voidopen virtual
voidclose virtual

open

virtual

virtual void open()

close

virtual

virtual void close()