LogStream subclass for directing a log stream to file.
More...
#include <Workspace/DataExecution/Logging/logtofile.h>
Because logging information is often needed as a diagnostic aid when developing operations, all calls to logText() are immediately followed by a call to flush(). This ensures that logged text is seen as soon as possible and it minimizes the chances of logged text being lost in the event of a crash.
◆ LogToFile()
LogToFile |
( |
const QString & |
fileName, |
|
|
bool |
append = false |
|
) |
| |
- Parameters
-
fileName | The name of the file where logged text should be sent. |
append | If a file with the specified fileName already exists, this parameter controls whether text will be appended to it (append == true) or whether the old contents are discarded (append == false). |
The constructor attempts to open a file with the specified fileName for writing. No check is performed for whether or not this succeeds, so if clients want to know this they will have to call isStreamOkay().
◆ ~LogToFile()
◆ flush()
Clients would not normally need to call this function, but if for some reason they want to be sure that all logged text has been sent to where it needs to go before performing some task, they can call flush(). When flush() returns, all underlying streams and buffers associated with the LogStream object will have been flushed to disk, etc.
Implements LogStream.
◆ getFileName()
QString getFileName |
( |
| ) |
const |
◆ getPrefixTimestamp()
bool getPrefixTimestamp |
( |
| ) |
const |
◆ isStreamOkay()
bool isStreamOkay |
( |
| ) |
const |
|
overridevirtual |
- Returns
- True if the stream is able to accept text for writing.
Implements LogStream.
◆ setPrefixTimestamp()
void setPrefixTimestamp |
( |
bool |
enable | ) |
|