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

char * 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)
 
int pid () const
 
qlonglong tid () const
 
qulonglong threadId () const
 
uint usec () const
 
int line () const
 
int type () const
 
int level () const
 
int facility () const
 
qlonglong epoch () 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 setUsec (const uint val)
 
void setLine (const int val)
 
void setType (const int val)
 
void setLevel (const int val)
 
void setFacility (const int val)
 
void setEpoch (const qlonglong val)
 
void setFile (const QString &val) SET_LOGGING_ARG(m_file) void setFunction(const QString &val) SET_LOGGING_ARG(m_function) void setThreadName(const QString &val) SET_LOGGING_ARG(m_threadName) void setAppName(const QString &val) SET_LOGGING_ARG(m_appName) void setTable(const QString &val) SET_LOGGING_ARG(m_table) void setLogFile(const QString &val) SET_LOGGING_ARG(m_logFile) void setMessage(const QString &val)
 
const char * rawFile () const
 
const char * rawFunction () const
 
const char * rawThreadName () const
 
const char * rawAppName () const
 
const char * rawTable () const
 
const char * rawLogFile () const
 
const char * rawMessage () const
 
- 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 *, const char *, int, LogLevel_t, LoggingType)
 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 {(qulonglong)-1}
 
uint m_usec {0}
 
int m_line {0}
 
LoggingType m_type {kMessage}
 
LogLevel_t m_level {LOG_INFO}
 
int m_facility {0}
 
qlonglong m_epoch {0}
 
char * m_file {nullptr}
 
char * m_function {nullptr}
 
char * m_threadName {nullptr}
 
char * m_appName {nullptr}
 
char * m_table {nullptr}
 
char * m_logFile {nullptr}
 
char m_message [LOGLINE_MAX+1]
 
- 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
 
uint usec
 
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)
 
 ~LoggingItem ()
 
 Q_DISABLE_COPY (LoggingItem)
 

Friends

class LoggerThread
 
void LogPrintLine (uint64_t, LogLevel_t, const char *, int, const char *, int, const char *,...)
 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 62 of file logging.h.

Constructor & Destructor Documentation

◆ LoggingItem() [1/2]

LoggingItem::LoggingItem ( )
private

Definition at line 140 of file logging.cpp.

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 147 of file logging.cpp.

◆ ~LoggingItem()

LoggingItem::~LoggingItem ( )
private

Definition at line 161 of file logging.cpp.

Member Function Documentation

◆ getThreadName()

char * LoggingItem::getThreadName ( void  )

Get the name of the thread that produced the LoggingItem.

Returns
C-string of the thread name

Definition at line 188 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 204 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 217 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 553 of file logging.cpp.

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

◆ create() [2/2]

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

Definition at line 563 of file logging.cpp.

◆ toByteArray()

QByteArray LoggingItem::toByteArray ( void  )

Definition at line 176 of file logging.cpp.

Referenced by LoggerThread::handleItem().

◆ pid()

int LoggingItem::pid ( ) const
inline

Definition at line 96 of file logging.h.

◆ tid()

qlonglong LoggingItem::tid ( ) const
inline

Definition at line 97 of file logging.h.

◆ threadId()

qulonglong LoggingItem::threadId ( ) const
inline

Definition at line 98 of file logging.h.

◆ usec()

uint LoggingItem::usec ( ) const
inline

Definition at line 99 of file logging.h.

◆ line()

int LoggingItem::line ( ) const
inline

Definition at line 100 of file logging.h.

◆ type()

int LoggingItem::type ( ) const
inline

Definition at line 101 of file logging.h.

◆ level()

int LoggingItem::level ( ) const
inline

Definition at line 102 of file logging.h.

◆ facility()

int LoggingItem::facility ( ) const
inline

Definition at line 103 of file logging.h.

◆ epoch()

qlonglong LoggingItem::epoch ( ) const
inline

Definition at line 104 of file logging.h.

◆ file()

QString LoggingItem::file ( ) const
inline

Definition at line 105 of file logging.h.

◆ function()

QString LoggingItem::function ( ) const
inline

Definition at line 106 of file logging.h.

◆ threadName()

QString LoggingItem::threadName ( ) const
inline

Definition at line 107 of file logging.h.

◆ appName()

QString LoggingItem::appName ( ) const
inline

Definition at line 108 of file logging.h.

◆ table()

QString LoggingItem::table ( ) const
inline

Definition at line 109 of file logging.h.

◆ logFile()

QString LoggingItem::logFile ( ) const
inline

Definition at line 110 of file logging.h.

◆ message()

QString LoggingItem::message ( ) const
inline

Definition at line 111 of file logging.h.

◆ setPid()

void LoggingItem::setPid ( const int  val)
inline

Definition at line 113 of file logging.h.

Referenced by LoggerThread::fillItem().

◆ setTid()

void LoggingItem::setTid ( const qlonglong  val)
inline

Definition at line 114 of file logging.h.

◆ setThreadId()

void LoggingItem::setThreadId ( const qulonglong  val)
inline

Definition at line 115 of file logging.h.

◆ setUsec()

void LoggingItem::setUsec ( const uint  val)
inline

Definition at line 116 of file logging.h.

◆ setLine()

void LoggingItem::setLine ( const int  val)
inline

Definition at line 117 of file logging.h.

◆ setType()

void LoggingItem::setType ( const int  val)
inline

Definition at line 118 of file logging.h.

◆ setLevel()

void LoggingItem::setLevel ( const int  val)
inline

Definition at line 119 of file logging.h.

◆ setFacility()

void LoggingItem::setFacility ( const int  val)
inline

Definition at line 120 of file logging.h.

Referenced by LoggerThread::fillItem().

◆ setEpoch()

void LoggingItem::setEpoch ( const qlonglong  val)
inline

Definition at line 121 of file logging.h.

◆ setFile()

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

Definition at line 122 of file logging.h.

◆ rawFile()

const char* LoggingItem::rawFile ( ) const
inline

Definition at line 134 of file logging.h.

Referenced by FileLogger::logmsg().

◆ rawFunction()

const char* LoggingItem::rawFunction ( ) const
inline

Definition at line 135 of file logging.h.

Referenced by FileLogger::logmsg().

◆ rawThreadName()

const char* LoggingItem::rawThreadName ( ) const
inline

Definition at line 136 of file logging.h.

Referenced by FileLogger::logmsg().

◆ rawAppName()

const char* LoggingItem::rawAppName ( ) const
inline

Definition at line 137 of file logging.h.

◆ rawTable()

const char* LoggingItem::rawTable ( ) const
inline

Definition at line 138 of file logging.h.

◆ rawLogFile()

const char* LoggingItem::rawLogFile ( ) const
inline

Definition at line 139 of file logging.h.

◆ rawMessage()

const char* LoggingItem::rawMessage ( ) const
inline

Definition at line 140 of file logging.h.

Referenced by FileLogger::logmsg().

◆ Q_DISABLE_COPY()

LoggingItem::Q_DISABLE_COPY ( LoggingItem  )
private

Friends And Related Function Documentation

◆ LoggerThread

friend class LoggerThread
friend

Definition at line 83 of file logging.h.

◆ LogPrintLine

void LogPrintLine ( uint64_t  mask,
LogLevel_t  level,
const char *  file,
int  line,
const char *  function,
int  fromQString,
const char *  format,
  ... 
)
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
fromQStringtrue if this message originated from QString
formatprintf format string (when not from QString), log message (when from QString)
...printf arguments (when not from QString)

Definition at line 586 of file logging.cpp.

Member Data Documentation

◆ m_pid

int LoggingItem::m_pid {-1}
protected

Definition at line 143 of file logging.h.

Referenced by pid(), and setPid().

◆ m_tid

qlonglong LoggingItem::m_tid {-1}
protected

Definition at line 144 of file logging.h.

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

◆ m_threadId

qulonglong LoggingItem::m_threadId {(qulonglong)-1}
protected

◆ m_usec

uint LoggingItem::m_usec {0}
protected

Definition at line 146 of file logging.h.

Referenced by LoggerThread::logConsole(), LoggingItem(), setUsec(), and usec().

◆ m_line

int LoggingItem::m_line {0}
protected

Definition at line 147 of file logging.h.

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

◆ m_type

LoggingType LoggingItem::m_type {kMessage}
protected

Definition at line 148 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 149 of file logging.h.

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

◆ m_facility

int LoggingItem::m_facility {0}
protected

Definition at line 150 of file logging.h.

Referenced by facility(), and setFacility().

◆ m_epoch

qlonglong LoggingItem::m_epoch {0}
protected

Definition at line 151 of file logging.h.

Referenced by epoch(), LoggingItem(), and setEpoch().

◆ m_file

char* LoggingItem::m_file {nullptr}
protected

Definition at line 152 of file logging.h.

Referenced by file(), LoggerThread::logConsole(), rawFile(), and ~LoggingItem().

◆ m_function

char* LoggingItem::m_function {nullptr}
protected

Definition at line 153 of file logging.h.

Referenced by function(), LoggerThread::logConsole(), rawFunction(), and ~LoggingItem().

◆ m_threadName

char* LoggingItem::m_threadName {nullptr}
protected

◆ m_appName

char* LoggingItem::m_appName {nullptr}
protected

Definition at line 155 of file logging.h.

Referenced by appName(), rawAppName(), and ~LoggingItem().

◆ m_table

char* LoggingItem::m_table {nullptr}
protected

Definition at line 156 of file logging.h.

Referenced by rawTable(), table(), and ~LoggingItem().

◆ m_logFile

char* LoggingItem::m_logFile {nullptr}
protected

Definition at line 157 of file logging.h.

Referenced by logFile(), rawLogFile(), and ~LoggingItem().

◆ m_message

char LoggingItem::m_message[LOGLINE_MAX+1]
protected

Property Documentation

◆ pid

int LoggingItem::pid
readwrite

Definition at line 66 of file logging.h.

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

◆ tid

qlonglong LoggingItem::tid
readwrite

Definition at line 67 of file logging.h.

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

◆ threadId

qulonglong LoggingItem::threadId
readwrite

Definition at line 68 of file logging.h.

◆ usec

uint LoggingItem::usec
readwrite

Definition at line 69 of file logging.h.

Referenced by FileLogger::logmsg().

◆ line

int LoggingItem::line
readwrite

Definition at line 70 of file logging.h.

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

◆ type

int LoggingItem::type
readwrite

Definition at line 71 of file logging.h.

◆ level

int LoggingItem::level
readwrite

Definition at line 72 of file logging.h.

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

◆ facility

int LoggingItem::facility
readwrite

Definition at line 73 of file logging.h.

Referenced by LogForwardThread::forwardMessage().

◆ epoch

qlonglong LoggingItem::epoch
readwrite

Definition at line 74 of file logging.h.

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

◆ file

QString LoggingItem::file
readwrite

Definition at line 75 of file logging.h.

Referenced by DatabaseLogger::logqmsg().

◆ function

QString LoggingItem::function
readwrite

Definition at line 76 of file logging.h.

Referenced by DatabaseLogger::logqmsg().

◆ threadName

QString LoggingItem::threadName
readwrite

Definition at line 77 of file logging.h.

Referenced by DatabaseLogger::logqmsg().

◆ appName

QString LoggingItem::appName
readwrite

Definition at line 78 of file logging.h.

Referenced by DatabaseLogger::logqmsg().

◆ table

QString LoggingItem::table
readwrite

Definition at line 79 of file logging.h.

Referenced by LogForwardThread::forwardMessage().

◆ logFile

QString LoggingItem::logFile
readwrite

Definition at line 80 of file logging.h.

Referenced by LogForwardThread::forwardMessage().

◆ message

QString LoggingItem::message
readwrite

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