MythTV
master
|
Database logger - logs to the MythTV database. More...
#include <loggingserver.h>
Public Member Functions | |
DatabaseLogger (const char *table) | |
DatabaseLogger constructor. More... | |
~DatabaseLogger () override | |
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... | |
![]() | |
LoggerBase (const char *string) | |
LoggerBase Constructor. More... | |
~LoggerBase () override | |
LoggerBase Deconstructor. More... | |
Static Public Member Functions | |
static DatabaseLogger * | create (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... | |
Static Private Member Functions | |
static bool | tableExists (const QString &table) |
Checks whether table exists and is ready for writing. More... | |
Private Attributes | |
DBLoggerThread * | m_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... | |
QElapsedTimer | m_disabledTime |
Elapsed time since the DB logging was disabled. More... | |
QElapsedTimer | m_errorLoggingTime |
Elapsed time since DB error logging was last done. More... | |
Static Private Attributes | |
static constexpr std::chrono::milliseconds | kMinDisabledTime {1s} |
Minimum time to disable DB logging. More... | |
Friends | |
class | DBLoggerThread |
Additional Inherited Members | |
![]() | |
QString | m_handle {} |
semi-opaque handle for identifying instance More... | |
Database logger - logs to the MythTV database.
Definition at line 99 of file loggingserver.h.
|
explicit |
DatabaseLogger constructor.
table | C-string of the database table to log to |
Definition at line 317 of file loggingserver.cpp.
Referenced by create().
|
override |
DatabaseLogger deconstructor.
Definition at line 336 of file loggingserver.cpp.
|
overridevirtual |
Process a log message, queuing it for logging to the database.
item | LoggingItem containing the log message to process |
Implements LoggerBase.
Definition at line 378 of file loggingserver.cpp.
|
inlineoverridevirtual |
Reopen the log file to facilitate log rolling.
Implements LoggerBase.
Definition at line 108 of file loggingserver.h.
|
overridevirtual |
Stop logging to the database and wait for the thread to stop.
Reimplemented from LoggerBase.
Definition at line 365 of file loggingserver.cpp.
Referenced by ~DatabaseLogger().
|
static |
Definition at line 343 of file loggingserver.cpp.
Referenced by LogForwardThread::forwardMessage().
|
protected |
Actually insert a log message from the queue into the database.
query | The database insert query to use |
item | LoggingItem containing the log message to insert |
Definition at line 416 of file loggingserver.cpp.
Referenced by DBLoggerThread::run().
|
protected |
Prepare the database query for use, and bind constant values to it.
query | The database query to prepare |
Definition at line 454 of file loggingserver.cpp.
Referenced by DBLoggerThread::run().
|
private |
Check if the database is ready for use.
Definition at line 462 of file loggingserver.cpp.
Referenced by logmsg(), and DBLoggerThread::run().
|
staticprivate |
Checks whether table exists and is ready for writing.
table | The name of the table to check (without schema name) |
Definition at line 482 of file loggingserver.cpp.
Referenced by isDatabaseReady().
|
friend |
Definition at line 103 of file loggingserver.h.
Referenced by DatabaseLogger().
|
private |
The database queue handling thread.
Definition at line 118 of file loggingserver.h.
Referenced by DatabaseLogger(), logmsg(), and stopDatabaseAccess().
|
private |
The database query to insert log messages.
Definition at line 119 of file loggingserver.h.
Referenced by DatabaseLogger(), and prepare().
The database is opened.
Definition at line 120 of file loggingserver.h.
The desired logging table exists.
Definition at line 121 of file loggingserver.h.
Referenced by isDatabaseReady().
|
private |
Elapsed time since the DB logging was disabled.
Definition at line 122 of file loggingserver.h.
Referenced by logmsg().
|
private |
Elapsed time since DB error logging was last done.
Definition at line 123 of file loggingserver.h.
Referenced by logqmsg().
|
staticconstexprprivate |
Minimum time to disable DB logging.
Definition at line 124 of file loggingserver.h.
Referenced by logmsg().