MythTV  master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
DatabaseLogger Class Reference

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

#include <loggingserver.h>

Inheritance diagram for DatabaseLogger:
Inheritance graph
[legend]
Collaboration diagram for DatabaseLogger:
Collaboration graph
[legend]

Public Member Functions

 DatabaseLogger (const char *table)
 DatabaseLogger constructor. More...
 
 ~DatabaseLogger ()
 DatabaseLogger deconstructor. More...
 
bool logmsg (LoggingItem *item) override
 Process a log message, queuing it for logging to the database. More...
 
void reopen (void) override
 Reopen the log file to facilitate log rolling. More...
 
void stopDatabaseAccess (void) override
 Stop logging to the database and wait for the thread to stop. More...
 
- Public Member Functions inherited from LoggerBase
 LoggerBase (const char *string)
 LoggerBase Constructor. More...
 
virtual ~LoggerBase ()
 LoggerBase Deconstructor. More...
 

Static Public Member Functions

static DatabaseLoggercreate (const QString &table, QMutex *mutex)
 

Protected Member Functions

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

Private Member Functions

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

Private Attributes

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

Static Private Attributes

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

Friends

class DBLoggerThread
 

Additional Inherited Members

- Protected Attributes inherited from LoggerBase
char * m_handle {nullptr}
 semi-opaque handle for identifying instance More...
 

Detailed Description

Database logger - logs to the MythTV database.

Definition at line 98 of file loggingserver.h.

Constructor & Destructor Documentation

◆ DatabaseLogger()

DatabaseLogger::DatabaseLogger ( const char *  table)
explicit

DatabaseLogger constructor.

Parameters
tableC-string of the database table to log to

Definition at line 360 of file loggingserver.cpp.

Referenced by create().

◆ ~DatabaseLogger()

DatabaseLogger::~DatabaseLogger ( )

DatabaseLogger deconstructor.

Definition at line 379 of file loggingserver.cpp.

Member Function Documentation

◆ logmsg()

bool DatabaseLogger::logmsg ( LoggingItem item)
overridevirtual

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

Parameters
itemLoggingItem containing the log message to process

Implements LoggerBase.

Definition at line 421 of file loggingserver.cpp.

◆ reopen()

void DatabaseLogger::reopen ( void  )
inlineoverridevirtual

Reopen the log file to facilitate log rolling.

Implements LoggerBase.

Definition at line 107 of file loggingserver.h.

◆ stopDatabaseAccess()

void DatabaseLogger::stopDatabaseAccess ( void  )
overridevirtual

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

Reimplemented from LoggerBase.

Definition at line 408 of file loggingserver.cpp.

Referenced by ~DatabaseLogger().

◆ create()

DatabaseLogger * DatabaseLogger::create ( const QString &  table,
QMutex *  mutex 
)
static

Definition at line 386 of file loggingserver.cpp.

Referenced by LogForwardThread::forwardMessage().

◆ logqmsg()

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

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

Parameters
queryThe database insert query to use
itemLoggingItem containing the log message to insert

Definition at line 461 of file loggingserver.cpp.

Referenced by DBLoggerThread::run().

◆ prepare()

void DatabaseLogger::prepare ( MSqlQuery query)
protected

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

Parameters
queryThe database query to prepare

Definition at line 506 of file loggingserver.cpp.

Referenced by DBLoggerThread::run().

◆ isDatabaseReady()

bool DatabaseLogger::isDatabaseReady ( void  )
private

Check if the database is ready for use.

Returns
true when database is ready, false otherwise

Definition at line 514 of file loggingserver.cpp.

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

◆ tableExists()

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

Checks whether table exists and is ready for writing.

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

Definition at line 534 of file loggingserver.cpp.

Referenced by isDatabaseReady().

Friends And Related Function Documentation

◆ DBLoggerThread

friend class DBLoggerThread
friend

Definition at line 102 of file loggingserver.h.

Referenced by DatabaseLogger().

Member Data Documentation

◆ m_thread

DBLoggerThread* DatabaseLogger::m_thread
private

The database queue handling thread.

Definition at line 117 of file loggingserver.h.

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

◆ m_query

QString DatabaseLogger::m_query
private

The database query to insert log messages.

Definition at line 118 of file loggingserver.h.

Referenced by DatabaseLogger(), and prepare().

◆ m_opened

bool DatabaseLogger::m_opened {true}
private

The database is opened.

Definition at line 119 of file loggingserver.h.

◆ m_loggingTableExists

bool DatabaseLogger::m_loggingTableExists {false}
private

The desired logging table exists.

Definition at line 120 of file loggingserver.h.

Referenced by isDatabaseReady().

◆ m_disabled

bool DatabaseLogger::m_disabled {false}
private

DB logging is temporarily disabled.

Definition at line 121 of file loggingserver.h.

Referenced by logmsg().

◆ m_disabledTime

QTime DatabaseLogger::m_disabledTime
private

Time when the DB logging was disabled.

Definition at line 122 of file loggingserver.h.

Referenced by logmsg().

◆ m_errorLoggingTime

QTime DatabaseLogger::m_errorLoggingTime
private

Time when DB error logging was last done.

Definition at line 123 of file loggingserver.h.

Referenced by logqmsg().

◆ kMinDisabledTime

const int DatabaseLogger::kMinDisabledTime = 1000
staticprivate

Minimum time to disable DB logging (in ms)

Definition at line 124 of file loggingserver.h.

Referenced by logmsg().


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