Home
Base module

FileChannel

Log channel that writes formatted messages to a file.

FileChannel

#include <icy/logger.h>
class FileChannel

Defined in src/base/include/icy/logger.h:437

Inherits: LogChannel

Log channel that writes formatted messages to a file.

List of all members

NameKindOwner
FileChannelfunctionDeclared here
~FileChannelfunctionDeclared here
writefunctionDeclared here
setPathfunctionDeclared here
pathfunctionDeclared here
_fstreamvariableDeclared here
_pathvariableDeclared here
openfunctionDeclared here
closefunctionDeclared here
LogChannelfunctionInherited from LogChannel
~LogChannelfunctionInherited from LogChannel
writefunctionInherited from LogChannel
writefunctionInherited from LogChannel
formatfunctionInherited from LogChannel
namefunctionInherited from LogChannel
levelfunctionInherited from LogChannel
timeFormatfunctionInherited from LogChannel
setLevelfunctionInherited from LogChannel
setTimeFormatfunctionInherited from LogChannel
setFilterfunctionInherited from LogChannel
_namevariableInherited from LogChannel
_levelvariableInherited from LogChannel
_timeFormatvariableInherited from LogChannel
_filtervariableInherited from LogChannel

Inherited from LogChannel

KindNameDescription
functionLogChannel
function~LogChannel virtualDefaulted destructor.
functionwrite virtualWrites a log stream entry to this channel.
functionwrite virtualWrites a plain message to this channel.
functionformat virtualFormats a log stream entry into the given output stream.
functionname const inlineReturns the channel name.
functionlevel const inlineReturns the minimum severity level.
functiontimeFormat const inlineReturns the timestamp format string.
functionsetLevel inlineSets the minimum severity level.
functionsetTimeFormat inlineSets the timestamp format string.
functionsetFilter inlineSets a realm filter; only messages whose realm matches are written.
variable_name
variable_level
variable_timeFormat
variable_filter

Public Methods

ReturnNameDescription
FileChannel
voidwrite virtual overrideFormats 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 = Level::Debug, std::string timeFormat = "%H:%M:%S")

Defined in src/base/include/icy/logger.h:444

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 override

virtual void write(const LogStream & stream) override

Defined in src/base/include/icy/logger.h:452

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.
Reimplements

setPath

void setPath(const std::string & path)

Defined in src/base/include/icy/logger.h:456

Sets the file path and reopens the file stream.

Parameters

  • path Path to the new log file.

path

const

std::string path() const

Defined in src/base/include/icy/logger.h:460

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

Defined in src/base/include/icy/logger.h:467


_path

std::string _path

Defined in src/base/include/icy/logger.h:468

Protected Methods

ReturnNameDescription
voidopen virtual
voidclose virtual

open

virtual

virtual void open()

Defined in src/base/include/icy/logger.h:463


close

virtual

virtual void close()

Defined in src/base/include/icy/logger.h:464