QtCraft API C++ classes QML types Handbook

QcLogWriter Class

One log file with a size cap (decision E-834): lines are appended unbuffered, so a crash loses none of them; when the file would grow beyond the cap it becomes the rotated part 1, older parts move up by one, the oldest beyond rotations is deleted and a new file starts. More...

Header: #include <common/diagnostics/QcLogWriter.h>

Public Types

struct Limits

Public Functions

int handle() const
QcStatus open()
QString path() const
bool rotatesFor(qsizetype bytes) const
int rotationCount() const
void write(const QByteArray &line)

Detailed Description

Not thread-safe: QcMessageLog writes under its mutex.

Member Function Documentation

int QcLogWriter::handle() const

Returns the operating system's handle of the open file (for the crash handler); -1 when closed.

QcStatus QcLogWriter::open()

Opens the file for appending (making its folder); returns an error that says why it cannot.

QString QcLogWriter::path() const

Returns the path of the current file.

bool QcLogWriter::rotatesFor(qsizetype bytes) const

Returns whether writing bytes more starts a new file (closing the current one and its handle).

int QcLogWriter::rotationCount() const

Returns the rotations so far (tests).

void QcLogWriter::write(const QByteArray &line)

Appends line, rotating first when it would grow the file beyond the cap; does nothing while the file is not open.