Log4Qt::FileAppender Class Reference

The class FileAppender appends log events to a file. More...

#include <fileappender.h>

Inheritance diagram for Log4Qt::FileAppender:

Log4Qt::WriterAppender Log4Qt::AppenderSkeleton Log4Qt::Appender Log4Qt::LogObject Log4Qt::DailyRollingFileAppender Log4Qt::RollingFileAppender

List of all members.

Public Member Functions

 FileAppender (QObject *pParent=0)
 FileAppender (Layout *pLayout, const QString &rFileName, QObject *pParent=0)
 FileAppender (Layout *pLayout, const QString &rFileName, bool append, QObject *pParent=0)
 FileAppender (Layout *pLayout, const QString &rFileName, bool append, bool buffered, QObject *pParent=0)
virtual ~FileAppender ()
bool appendFile () const
QString file () const
bool bufferedIo () const
void setAppendFile (bool append)
void setBufferedIo (bool buffered)
void setFile (const QString &rFileName)
virtual void activateOptions ()
virtual void close ()

Protected Member Functions

virtual bool checkEntryConditions () const
void closeFile ()
virtual QDebug debug (QDebug &rDebug) const
virtual bool handleIoErrors () const
void openFile ()
bool removeFile (QFile &rFile) const
bool renameFile (QFile &rFile, const QString &rFileName) const

Properties

bool appendFile
bool bufferedIo
QString file


Detailed Description

The class FileAppender appends log events to a file.

Note:
All the functions declared in this class are thread-safe.

The ownership and lifetime of objects of this class are managed. See Object ownership for more details.


Constructor & Destructor Documentation

Log4Qt::FileAppender::FileAppender ( QObject *  pParent = 0  ) 

Log4Qt::FileAppender::FileAppender ( Layout pLayout,
const QString &  rFileName,
QObject *  pParent = 0 
)

Log4Qt::FileAppender::FileAppender ( Layout pLayout,
const QString &  rFileName,
bool  append,
QObject *  pParent = 0 
)

Log4Qt::FileAppender::FileAppender ( Layout pLayout,
const QString &  rFileName,
bool  append,
bool  buffered,
QObject *  pParent = 0 
)

virtual Log4Qt::FileAppender::~FileAppender (  )  [virtual]


Member Function Documentation

bool Log4Qt::FileAppender::appendFile (  )  const

QString Log4Qt::FileAppender::file (  )  const

bool Log4Qt::FileAppender::bufferedIo (  )  const

void Log4Qt::FileAppender::setAppendFile ( bool  append  )  [inline]

void Log4Qt::FileAppender::setBufferedIo ( bool  buffered  )  [inline]

void Log4Qt::FileAppender::setFile ( const QString &  rFileName  )  [inline]

virtual void Log4Qt::FileAppender::activateOptions (  )  [virtual]

Reimplemented from Log4Qt::WriterAppender.

Reimplemented in Log4Qt::DailyRollingFileAppender.

virtual void Log4Qt::FileAppender::close (  )  [virtual]

Reimplemented from Log4Qt::WriterAppender.

virtual bool Log4Qt::FileAppender::checkEntryConditions (  )  const [protected, virtual]

Tests if all entry conditions for using append() in this class are met.

If a conditions is not met, an error is logged and the function returns false. Otherwise the result of WriterAppender::checkEntryConditions() is returned.

The checked conditions are:

  • That a file is set and open (APPENDER_NO_OPEN_FILE_ERROR)

The function is called as part of the checkEntryConditions() chain started by AppenderSkeleton::doAppend().

See also:
AppenderSkeleton::doAppend(), AppenderSkeleton::checkEntryConditions()

Reimplemented from Log4Qt::WriterAppender.

Reimplemented in Log4Qt::DailyRollingFileAppender.

void Log4Qt::FileAppender::closeFile (  )  [protected]

virtual QDebug Log4Qt::FileAppender::debug ( QDebug &  rDebug  )  const [protected, virtual]

Writes all object member variables to the given debug stream rDebug and returns the stream.

FileAppender(name:"FA" appendfile:false bufferedio:true encoding:"" file:"/log.txt" filter: 0x0 immediateflush:true isactive:false isclosed:false layout:"TTCC" referencecount:2 threshold:"NULL" writer:0x0)

See also:
QDebug, operator<<(QDebug debug, const LogObject &rLogObject)

Reimplemented from Log4Qt::WriterAppender.

Reimplemented in Log4Qt::DailyRollingFileAppender, and Log4Qt::RollingFileAppender.

virtual bool Log4Qt::FileAppender::handleIoErrors (  )  const [protected, virtual]

Checks for file I/O errrors. If an error is found it is logged and the function returns true. Otherwise false is returned.

Reimplemented from Log4Qt::WriterAppender.

void Log4Qt::FileAppender::openFile (  )  [protected]

Opens the file for the appender based on the specified file name and mode. A text stream is created and passed on to the super class WriterAppender.

If the parent directory of the specified file does not exists, it is created.

bool Log4Qt::FileAppender::removeFile ( QFile &  rFile  )  const [protected]

Removes the file rFile. If the operation is successful, true is returned. Otherwise an APPENDER_REMOVE_FILE_ERROR error is logged and false is returned.

bool Log4Qt::FileAppender::renameFile ( QFile &  rFile,
const QString &  rFileName 
) const [protected]

Renames the file rFile to rFileName. If the operation is successful, true is returned. Otherwise an APPENDER_RENAMING_FILE_ERROR error is logged and false is returned.


Property Documentation

bool Log4Qt::FileAppender::appendFile [inline, read, write]

The property holds, if the output is appended to the file.

The default is false for not appending.

See also:
appendFile(), setAppendFile()

bool Log4Qt::FileAppender::bufferedIo [inline, read, write]

The property holds, if the output is buffered.

The default is true for buffering.

See also:
bufferedIo(), setBufferedIo()

QString Log4Qt::FileAppender::file [inline, read, write]

The property holds the name of the file.

See also:
file(), setFile()


The documentation for this class was generated from the following file:

Generated on Sun Mar 1 16:40:45 2009 for Log4Qt by  doxygen 1.5.6