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

The logging items that are generated by LOG() and are sent to the console. More...

#include <logging.h>

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

Public Member Functions

QString getThreadName (void)
 Get the name of the thread that produced the LoggingItem. More...
 
int64_t getThreadTid (void)
 Get the thread ID of the thread that produced the LoggingItem. More...
 
void setThreadTid (void)
 Set the thread ID of the thread that produced the LoggingItem. More...
 
QByteArray toByteArray (void)
 
QString getTimestamp (const char *format="yyyy-MM-dd HH:mm:ss") const
 Convert numerical timestamp to a readable date and time. More...
 
QString getTimestampUs (const char *format="yyyy-MM-dd HH:mm:ss") const
 
char getLevelChar (void)
 Get the message log level as a single character. More...
 
int pid () const
 
qlonglong tid () const
 
qulonglong threadId () const
 
int line () const
 
int type () const
 
int level () const
 
int facility () const
 
std::chrono::microseconds epoch () const
 
qlonglong epochInt () const
 
QString file () const
 
QString function () const
 
QString threadName () const
 
QString appName () const
 
QString table () const
 
QString logFile () const
 
QString message () const
 
void setPid (const int val)
 
void setTid (const qlonglong val)
 
void setThreadId (const qulonglong val)
 
void setLine (const int val)
 
void setType (const int val)
 
void setLevel (const int val)
 
void setFacility (const int val)
 
void setEpoch (std::chrono::microseconds val)
 
void setEpochInt (const qlonglong val)
 
void setFile (const QString &val)
 
void setFunction (const QString &val)
 
void setThreadName (const QString &val)
 
void setAppName (const QString &val)
 
void setTable (const QString &val)
 
void setLogFile (const QString &val)
 
void setMessage (const QString &val)
 
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter (const QString &debugName, bool logDebug=true)
 Creates reference counter with an initial value of 1. More...
 
virtual int IncrRef (void)
 Increments reference count. More...
 
virtual int DecrRef (void)
 Decrements reference count and deletes on 0. More...
 

Static Public Member Functions

static LoggingItemcreate (const char *_file, const char *_function, int _line, LogLevel_t _level, LoggingType _type)
 Create a new LoggingItem. More...
 
static LoggingItemcreate (QByteArray &buf)
 
- Static Public Member Functions inherited from ReferenceCounter
static void PrintDebug (void)
 Print out any leaks if that level of debugging is enabled. More...
 

Protected Attributes

int m_pid {-1}
 
qlonglong m_tid {-1}
 
qulonglong m_threadId {UINT64_MAX}
 
int m_line {0}
 
LoggingType m_type {kMessage}
 
LogLevel_t m_level {LOG_INFO}
 
int m_facility {0}
 
std::chrono::microseconds m_epoch {0us}
 
QString m_file {}
 
QString m_function {}
 
QString m_threadName {}
 
QString m_appName {}
 
QString m_table {}
 
QString m_logFile {}
 
QString m_message {}
 
- Protected Attributes inherited from ReferenceCounter
bool m_logDebug
 This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More...
 
QAtomicInt m_referenceCount {1}
 

Properties

int pid
 
qlonglong tid
 
qulonglong threadId
 
int line
 
int type
 
int level
 
int facility
 
qlonglong epoch
 
QString file
 
QString function
 
QString threadName
 
QString appName
 
QString table
 
QString logFile
 
QString message
 

Private Member Functions

 LoggingItem ()
 
 LoggingItem (const char *_file, const char *_function, int _line, LogLevel_t _level, LoggingType _type)
 
 Q_DISABLE_COPY (LoggingItem)
 

Friends

class LoggerThread
 
void LogPrintLine (uint64_t mask, LogLevel_t level, const char *file, int line, const char *function, QString message)
 Format and send a log message into the queue. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ReferenceCounter
virtual ~ReferenceCounter (void)
 Called on destruction, will warn if object deleted with references in place. More...
 

Detailed Description

The logging items that are generated by LOG() and are sent to the console.

Definition at line 55 of file logging.h.

Constructor & Destructor Documentation

◆ LoggingItem() [1/2]

LoggingItem::LoggingItem ( )
inlineprivate

Definition at line 143 of file logging.h.

Referenced by create().

◆ LoggingItem() [2/2]

LoggingItem::LoggingItem ( const char *  _file,
const char *  _function,
int  _line,
LogLevel_t  _level,
LoggingType  _type 
)
private

Definition at line 125 of file logging.cpp.

Member Function Documentation

◆ getThreadName()

QString LoggingItem::getThreadName ( void  )

Get the name of the thread that produced the LoggingItem.

Returns
C-string of the thread name

Definition at line 148 of file logging.cpp.

Referenced by LoggerThread::fillItem().

◆ getThreadTid()

int64_t LoggingItem::getThreadTid ( void  )

Get the thread ID of the thread that produced the LoggingItem.

Returns
Thread ID of the producing thread, cast to a 64-bit signed integer
Note
In different platforms, the actual value returned here will vary. The intention is to get a thread ID that will map well to what is shown in gdb.

Definition at line 164 of file logging.cpp.

Referenced by LoggerThread::handleItem().

◆ setThreadTid()

void LoggingItem::setThreadTid ( void  )

Set the thread ID of the thread that produced the LoggingItem.

This code is actually run in the thread in question as part of the call to LOG()

Note
In different platforms, the actual value returned here will vary. The intention is to get a thread ID that will map well to what is shown in gdb.

Definition at line 177 of file logging.cpp.

Referenced by LoggingItem().

◆ create() [1/2]

LoggingItem * LoggingItem::create ( const char *  _file,
const char *  _function,
int  _line,
LogLevel_t  _level,
LoggingType  _type 
)
static

Create a new LoggingItem.

Parameters
_filefilename of the source file where the log message is from
_functionsource function where the log message is from
_lineline number in the source where the log message is from
_levellogging level of the message (LogLevel_t)
_typetype of logging message
Returns
LoggingItem that was created

Definition at line 533 of file logging.cpp.

Referenced by LogForwardThread::forwardMessage(), loggingDeregisterThread(), loggingRegisterThread(), and LogPrintLine().

◆ create() [2/2]

LoggingItem * LoggingItem::create ( QByteArray &  buf)
static

Definition at line 543 of file logging.cpp.

◆ toByteArray()

QByteArray LoggingItem::toByteArray ( void  )

Definition at line 136 of file logging.cpp.

Referenced by LoggerThread::handleItem().

◆ getTimestamp()

QString LoggingItem::getTimestamp ( const char *  format = "yyyy-MM-dd HH:mm:ss") const

Convert numerical timestamp to a readable date and time.

Definition at line 203 of file logging.cpp.

Referenced by getTimestampUs(), and DatabaseLogger::logqmsg().

◆ getTimestampUs()

QString LoggingItem::getTimestampUs ( const char *  format = "yyyy-MM-dd HH:mm:ss") const

Definition at line 210 of file logging.cpp.

Referenced by LoggerThread::logConsole(), and FileLogger::logmsg().

◆ getLevelChar()

char LoggingItem::getLevelChar ( void  )

Get the message log level as a single character.

Definition at line 218 of file logging.cpp.

Referenced by LoggerThread::logConsole(), and FileLogger::logmsg().

◆ pid()

int LoggingItem::pid ( ) const
inline

Definition at line 91 of file logging.h.

◆ tid()

qlonglong LoggingItem::tid ( ) const
inline

Definition at line 92 of file logging.h.

◆ threadId()

qulonglong LoggingItem::threadId ( ) const
inline

Definition at line 93 of file logging.h.

◆ line()

int LoggingItem::line ( ) const
inline

Definition at line 94 of file logging.h.

◆ type()

int LoggingItem::type ( ) const
inline

Definition at line 95 of file logging.h.

◆ level()

int LoggingItem::level ( ) const
inline

Definition at line 96 of file logging.h.

◆ facility()

int LoggingItem::facility ( ) const
inline

Definition at line 97 of file logging.h.

◆ epoch()

std::chrono::microseconds LoggingItem::epoch ( ) const
inline

Definition at line 98 of file logging.h.

◆ epochInt()

qlonglong LoggingItem::epochInt ( ) const
inline

Definition at line 99 of file logging.h.

◆ file()

QString LoggingItem::file ( ) const
inline

Definition at line 100 of file logging.h.

◆ function()

QString LoggingItem::function ( ) const
inline

Definition at line 101 of file logging.h.

◆ threadName()

QString LoggingItem::threadName ( ) const
inline

Definition at line 102 of file logging.h.

◆ appName()

QString LoggingItem::appName ( ) const
inline

Definition at line 103 of file logging.h.

◆ table()

QString LoggingItem::table ( ) const
inline

Definition at line 104 of file logging.h.

◆ logFile()

QString LoggingItem::logFile ( ) const
inline

Definition at line 105 of file logging.h.

◆ message()

QString LoggingItem::message ( ) const
inline

Definition at line 106 of file logging.h.

◆ setPid()

void LoggingItem::setPid ( const int  val)
inline

Definition at line 108 of file logging.h.

Referenced by LoggerThread::fillItem().

◆ setTid()

void LoggingItem::setTid ( const qlonglong  val)
inline

Definition at line 109 of file logging.h.

◆ setThreadId()

void LoggingItem::setThreadId ( const qulonglong  val)
inline

Definition at line 110 of file logging.h.

◆ setLine()

void LoggingItem::setLine ( const int  val)
inline

Definition at line 111 of file logging.h.

◆ setType()

void LoggingItem::setType ( const int  val)
inline

Definition at line 112 of file logging.h.

◆ setLevel()

void LoggingItem::setLevel ( const int  val)
inline

Definition at line 113 of file logging.h.

◆ setFacility()

void LoggingItem::setFacility ( const int  val)
inline

Definition at line 114 of file logging.h.

Referenced by LoggerThread::fillItem().

◆ setEpoch()

void LoggingItem::setEpoch ( std::chrono::microseconds  val)
inline

Definition at line 115 of file logging.h.

Referenced by setEpochInt().

◆ setEpochInt()

void LoggingItem::setEpochInt ( const qlonglong  val)
inline

Definition at line 116 of file logging.h.

◆ setFile()

void LoggingItem::setFile ( const QString &  val)
inline

Definition at line 117 of file logging.h.

◆ setFunction()

void LoggingItem::setFunction ( const QString &  val)
inline

Definition at line 118 of file logging.h.

◆ setThreadName()

void LoggingItem::setThreadName ( const QString &  val)
inline

Definition at line 119 of file logging.h.

Referenced by LoggerThread::fillItem(), and loggingRegisterThread().

◆ setAppName()

void LoggingItem::setAppName ( const QString &  val)
inline

Definition at line 120 of file logging.h.

Referenced by LoggerThread::fillItem().

◆ setTable()

void LoggingItem::setTable ( const QString &  val)
inline

Definition at line 121 of file logging.h.

Referenced by LoggerThread::fillItem().

◆ setLogFile()

void LoggingItem::setLogFile ( const QString &  val)
inline

Definition at line 122 of file logging.h.

Referenced by LoggerThread::fillItem().

◆ setMessage()

void LoggingItem::setMessage ( const QString &  val)
inline

Definition at line 123 of file logging.h.

◆ Q_DISABLE_COPY()

LoggingItem::Q_DISABLE_COPY ( LoggingItem  )
private

Friends And Related Function Documentation

◆ LoggerThread

friend class LoggerThread
friend

Definition at line 75 of file logging.h.

◆ LogPrintLine

void LogPrintLine ( uint64_t  mask,
LogLevel_t  level,
const char *  file,
int  line,
const char *  function,
QString  message 
)
friend

Format and send a log message into the queue.

This is called from the LOG() macro. The intention is minimal blocking of the caller.

Parameters
maskVerbosity mask of the message (VB_*)
levelLog level of this message (LOG_* - matching syslog levels)
fileFilename of source code logging the message
lineLine number within the source of log message source
functionFunction name of the log message source
messagelog message

Definition at line 563 of file logging.cpp.

Member Data Documentation

◆ m_pid

int LoggingItem::m_pid {-1}
protected

Definition at line 126 of file logging.h.

Referenced by pid(), and setPid().

◆ m_tid

qlonglong LoggingItem::m_tid {-1}
protected

Definition at line 127 of file logging.h.

Referenced by getThreadTid(), LoggerThread::handleItem(), setThreadTid(), setTid(), and tid().

◆ m_threadId

qulonglong LoggingItem::m_threadId {UINT64_MAX}
protected

◆ m_line

int LoggingItem::m_line {0}
protected

Definition at line 129 of file logging.h.

Referenced by line(), LoggerThread::logConsole(), and setLine().

◆ m_type

LoggingType LoggingItem::m_type {kMessage}
protected

Definition at line 130 of file logging.h.

Referenced by LoggerThread::handleItem(), LoggerThread::logConsole(), setType(), and type().

◆ m_level

LogLevel_t LoggingItem::m_level {LOG_INFO}
protected

Definition at line 131 of file logging.h.

Referenced by getLevelChar(), level(), LoggerThread::logConsole(), and setLevel().

◆ m_facility

int LoggingItem::m_facility {0}
protected

Definition at line 132 of file logging.h.

Referenced by facility(), and setFacility().

◆ m_epoch

std::chrono::microseconds LoggingItem::m_epoch {0us}
protected

Definition at line 133 of file logging.h.

Referenced by epoch(), epochInt(), getTimestamp(), getTimestampUs(), LoggingItem(), and setEpoch().

◆ m_file

QString LoggingItem::m_file {}
protected

Definition at line 134 of file logging.h.

Referenced by file(), LoggerThread::logConsole(), and setFile().

◆ m_function

QString LoggingItem::m_function {}
protected

Definition at line 135 of file logging.h.

Referenced by function(), LoggerThread::logConsole(), and setFunction().

◆ m_threadName

QString LoggingItem::m_threadName {}
protected

Definition at line 136 of file logging.h.

Referenced by getThreadName(), LoggerThread::handleItem(), setThreadName(), and threadName().

◆ m_appName

QString LoggingItem::m_appName {}
protected

Definition at line 137 of file logging.h.

Referenced by appName(), and setAppName().

◆ m_table

QString LoggingItem::m_table {}
protected

Definition at line 138 of file logging.h.

Referenced by setTable(), and table().

◆ m_logFile

QString LoggingItem::m_logFile {}
protected

Definition at line 139 of file logging.h.

Referenced by logFile(), and setLogFile().

◆ m_message

QString LoggingItem::m_message {}
protected

Property Documentation

◆ pid

int LoggingItem::pid
readwrite

Definition at line 59 of file logging.h.

Referenced by LoggerThread::logConsole(), FileLogger::logmsg(), and DatabaseLogger::logqmsg().

◆ tid

qlonglong LoggingItem::tid
readwrite

Definition at line 60 of file logging.h.

Referenced by LoggerThread::logConsole(), FileLogger::logmsg(), and DatabaseLogger::logqmsg().

◆ threadId

qulonglong LoggingItem::threadId
readwrite

Definition at line 61 of file logging.h.

◆ line

int LoggingItem::line
readwrite

Definition at line 62 of file logging.h.

Referenced by FileLogger::logmsg(), and DatabaseLogger::logqmsg().

◆ type

int LoggingItem::type
readwrite

Definition at line 63 of file logging.h.

◆ level

int LoggingItem::level
readwrite

Definition at line 64 of file logging.h.

Referenced by DatabaseLogger::logqmsg().

◆ facility

int LoggingItem::facility
readwrite

Definition at line 65 of file logging.h.

Referenced by LogForwardThread::forwardMessage().

◆ epoch

qlonglong LoggingItem::epoch
readwrite

Definition at line 66 of file logging.h.

Referenced by getTimestamp().

◆ file

QString LoggingItem::file
readwrite

Definition at line 67 of file logging.h.

Referenced by FileLogger::logmsg(), and DatabaseLogger::logqmsg().

◆ function

QString LoggingItem::function
readwrite

Definition at line 68 of file logging.h.

Referenced by FileLogger::logmsg(), and DatabaseLogger::logqmsg().

◆ threadName

QString LoggingItem::threadName
readwrite

Definition at line 69 of file logging.h.

Referenced by LoggerThread::logConsole(), FileLogger::logmsg(), and DatabaseLogger::logqmsg().

◆ appName

QString LoggingItem::appName
readwrite

Definition at line 70 of file logging.h.

Referenced by DatabaseLogger::logqmsg().

◆ table

QString LoggingItem::table
readwrite

Definition at line 71 of file logging.h.

Referenced by LogForwardThread::forwardMessage().

◆ logFile

QString LoggingItem::logFile
readwrite

Definition at line 72 of file logging.h.

Referenced by LogForwardThread::forwardMessage().

◆ message

QString LoggingItem::message
readwrite

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