DatabaseLogger Class Reference

Database logger - logs to the MythTV database. More...

#include <logging.h>

Inheritance diagram for DatabaseLogger:
LoggerBase

List of all members.

Public Member Functions

 DatabaseLogger (char *table)
 DatabaseLogger constructor.
 ~DatabaseLogger ()
 DatabaseLogger deconstructor.
bool logmsg (LoggingItem *item)
 Process a log message, queuing it for logging to the database.
void reopen (void)
 Reopen the log file to facilitate log rolling.
virtual void stopDatabaseAccess (void)
 Stop logging to the database and wait for the thread to stop.

Protected Member Functions

bool logqmsg (MSqlQuery &query, LoggingItem *item)
 Actually insert a log message from the queue into the database.
void prepare (MSqlQuery &query)
 Prepare the database query for use, and bind constant values to it.

Private Member Functions

bool isDatabaseReady (void)
 Check if the database is ready for use.
bool tableExists (const QString &table)
 Checks whether table exists and is ready for writing.

Private Attributes

DBLoggerThreadm_thread
 The database queue handling thread.
QString m_query
 The database query to insert log messages.
bool m_opened
 The database is opened.
bool m_loggingTableExists
 The desired logging table exists.
bool m_disabled
 DB logging is temporarily disabled.
QTime m_disabledTime
 Time when the DB logging was disabled.
QTime m_errorLoggingTime
 Time when DB error logging was last done.

Static Private Attributes

static const int kMinDisabledTime = 1000
 Minimum time to disable DB logging (in ms).

Friends

class DBLoggerThread

Detailed Description

Database logger - logs to the MythTV database.

Definition at line 86 of file libmythbase/logging.h.


Constructor & Destructor Documentation

DatabaseLogger::DatabaseLogger ( char *  table  ) 

DatabaseLogger constructor.

Parameters:
table C-string of the database table to log to

Definition at line 412 of file logging.cpp.

DatabaseLogger::~DatabaseLogger (  ) 

DatabaseLogger deconstructor.

Definition at line 435 of file logging.cpp.


Member Function Documentation

bool DatabaseLogger::logmsg ( LoggingItem item  )  [virtual]

Process a log message, queuing it for logging to the database.

Parameters:
item LoggingItem containing the log message to process

Implements LoggerBase.

Definition at line 456 of file logging.cpp.

void DatabaseLogger::reopen ( void   )  [inline, virtual]

Reopen the log file to facilitate log rolling.

Implements LoggerBase.

Definition at line 92 of file libmythbase/logging.h.

void DatabaseLogger::stopDatabaseAccess ( void   )  [virtual]

Stop logging to the database and wait for the thread to stop.

Reimplemented from LoggerBase.

Definition at line 443 of file logging.cpp.

Referenced by ~DatabaseLogger().

bool DatabaseLogger::logqmsg ( MSqlQuery query,
LoggingItem item 
) [protected]

Actually insert a log message from the queue into the database.

Parameters:
query The database insert query to use
item LoggingItem containing the log message to insert

Definition at line 496 of file logging.cpp.

Referenced by DBLoggerThread::run().

void DatabaseLogger::prepare ( MSqlQuery query  )  [protected]

Prepare the database query for use, and bind constant values to it.

Parameters:
query The database query to prepare

Definition at line 537 of file logging.cpp.

Referenced by DBLoggerThread::run().

bool DatabaseLogger::isDatabaseReady ( void   )  [private]

Check if the database is ready for use.

Returns:
true when database is ready, false otherwise

Definition at line 547 of file logging.cpp.

Referenced by logmsg(), and DBLoggerThread::run().

bool DatabaseLogger::tableExists ( const QString &  table  )  [private]

Checks whether table exists and is ready for writing.

Parameters:
table The name of the table to check (without schema name)
Returns:
true if table exists in schema or false if not

Definition at line 567 of file logging.cpp.

Referenced by isDatabaseReady().


Friends And Related Function Documentation

friend class DBLoggerThread [friend]

Definition at line 87 of file libmythbase/logging.h.

Referenced by DatabaseLogger().


Member Data Documentation

The database queue handling thread.

Definition at line 101 of file libmythbase/logging.h.

Referenced by DatabaseLogger(), logmsg(), and stopDatabaseAccess().

QString DatabaseLogger::m_query [private]

The database query to insert log messages.

Definition at line 102 of file libmythbase/logging.h.

Referenced by DatabaseLogger(), and prepare().

The database is opened.

Definition at line 103 of file libmythbase/logging.h.

Referenced by DatabaseLogger().

The desired logging table exists.

Definition at line 104 of file libmythbase/logging.h.

Referenced by isDatabaseReady().

DB logging is temporarily disabled.

Definition at line 105 of file libmythbase/logging.h.

Referenced by DatabaseLogger(), and logmsg().

Time when the DB logging was disabled.

Definition at line 106 of file libmythbase/logging.h.

Referenced by logmsg().

Time when DB error logging was last done.

Definition at line 107 of file libmythbase/logging.h.

Referenced by logqmsg().

const int DatabaseLogger::kMinDisabledTime = 1000 [static, private]

Minimum time to disable DB logging (in ms).

Definition at line 108 of file libmythbase/logging.h.

Referenced by logmsg().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Thu May 24 06:41:56 2012 for MythTV by  doxygen 1.6.3