MythTV  master
Macros | Functions | Variables
mythlogging.h File Reference
#include <QString>
#include <QStringList>
#include <cstdint>
#include <cerrno>
#include "mythbaseexp.h"
#include "verbosedefs.h"
Include dependency graph for mythlogging.h:

Go to the source code of this file.


#define LOG(_MASK_, _LEVEL_, _QSTRING_)
#define ENO   (QString("\n\t\t\teno: ") + logStrerror(errno))
 This can be appended to the LOG args with "+". More...
#define ENO_STR   ENO.toLocal8Bit().constData()


MBASE_PUBLIC 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...
static bool VERBOSE_LEVEL_NONE ()
static bool VERBOSE_LEVEL_CHECK (uint64_t mask, LogLevel_t level)
MBASE_PUBLIC void resetLogging (void)
 Intended for use only by the test harness. More...
MBASE_PUBLIC void logStart (const QString &logfile, bool progress=false, int quiet=0, int facility=0, LogLevel_t level=LOG_INFO, bool propagate=false, bool testHarness=false)
 Entry point to start logging for the application. More...
MBASE_PUBLIC void logStop (void)
 Entry point for stopping logging for an application. More...
MBASE_PUBLIC void logPropagateCalc (void)
 Generate the logPropagateArgs global with the latest logging level, mask, etc to propagate to all of the mythtv programs spawned from this one. More...
MBASE_PUBLIC bool logPropagateQuiet (void)
 Check if we are propagating a "--quiet". More...
MBASE_PUBLIC int syslogGetFacility (const QString &facility)
MBASE_PUBLIC LogLevel_t logLevelGet (const QString &level)
 Map a log level name back to the enumerated value. More...
MBASE_PUBLIC QString logLevelGetName (LogLevel_t level)
 Map a log level enumerated value back to the name. More...
MBASE_PUBLIC int verboseArgParse (const QString &arg)
 Parse the –verbose commandline argument and set the verbose level. More...
MBASE_PUBLIC QString logStrerror (int errnum)
 Verbose helper function for ENO macro. More...


MBASE_PUBLIC LogLevel_t logLevel
MBASE_PUBLIC uint64_t verboseMask
MBASE_PUBLIC ComponentLogLevelMap componentLogLevel
MBASE_PUBLIC QStringList logPropagateArgList
MBASE_PUBLIC QString logPropagateArgs
MBASE_PUBLIC QString verboseString

Macro Definition Documentation


#define LOG (   _MASK_,
do { \
if (VERBOSE_LEVEL_CHECK((_MASK_), (_LEVEL_)) && ((_LEVEL_)>=0)) \
{ \
LogPrintLine(_MASK_, _LEVEL_, \
__FILE__, __LINE__, __FUNCTION__, \
} \
} while (false)

Definition at line 39 of file mythlogging.h.


#define ENO   (QString("\n\t\t\teno: ") + logStrerror(errno))

This can be appended to the LOG args with "+".

Please do not use "<<". It uses a thread safe version of strerror to produce the string representation of errno and puts it on the next line in the verbose output.

Definition at line 73 of file mythlogging.h.


#define ENO_STR   ENO.toLocal8Bit().constData()

Definition at line 74 of file mythlogging.h.

Function Documentation

◆ LogPrintLine()

MBASE_PUBLIC 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.

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

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


static bool VERBOSE_LEVEL_NONE ( )


static bool VERBOSE_LEVEL_CHECK ( uint64_t  mask,
LogLevel_t  level 

Definition at line 29 of file mythlogging.h.

Referenced by SubtitleReader::AddAVSubtitle(), HTTPRequest::AddCORSHeaders(), MPEG2fixup::AddSequence(), avfDecoder::avfDecoder(), MythOpenGLPainter::Begin(), MHIContext::BeginStream(), CC608Decoder::BufferCC(), MPEG2fixup::ConvertToI(), MythRenderOpenGL::Create(), MythRenderOpenGL::CreateComputeShader(), MythRenderOpenGL::CreateShaderProgram(), MythEGLDMABUF::CreateTextures(), MythVideoColourSpace::Debug(), MythHTTPServer::DebugHosts(), MythDisplay::DebugModes(), MythHTTPServer::DebugOrigins(), MythRenderVulkan::DebugVulkan(), ProgramData::DeleteOverlaps(), SubtitleScreen::DisplayAVSubtitles(), SSDPCache::Dump(), MythPlayerUI::EnableFrameRateMonitor(), MythPainterVulkan::End(), MythOpenGLPainter::End(), MythVideoOutputOpenGL::EndFrame(), MSqlQuery::exec(), AutoExpire::ExpireEpisodesOverMax(), Scheduler::FillRecordingDir(), MythMediaDevice::findMountPath(), CardUtil::GetConflictingInputs(), MediaMonitorUnix::GetDeviceFile(), MainServer::GetFilesystemInfos(), MythHTTPParser::GetRequest(), FillData::GrabData(), ChannelScannerCLI::HandleEvent(), ChannelScannerWeb::HandleEvent(), MythRenderOpenGL::Init(), MPEG2fixup::InitAV(), CdDecoder::initialize(), MythRenderVulkan::initResources(), MPEG2fixup::InsertFrame(), InteractiveTV::InteractiveTV(), ChannelGroupSetting::LoadChannelGroup(), ImageLoader::LoadImage(), ChannelScanSM::LogLines(), myth_av_log(), myth_libass_log(), MythPainterWindowVulkan::MythPainterWindowVulkan(), MythVideoOutputOpenGL::MythVideoOutputOpenGL(), MythWindowVulkan::MythWindowVulkan(), ImportRecorder::Open(), DVBChannel::Open(), MythHTTPRanges::ParseRanges(), MythVideoVulkan::PrepareFrame(), MythVideoOutputOpenGL::PrepareFrame(), MythOpenGLVideo::PrepareFrame(), AudioInputALSA::PrepHwParams(), Scheduler::PrintList(), Scheduler::PrintRec(), MPEGStreamData::ProcessTSPacket(), MPEG2fixup::ProcessVideo(), EITCache::PruneOldEntries(), MythRAOPConnection::readClient(), MythSocket::ReadStringListReal(), MythRenderOpenGL::ReleaseResources(), MythVideoOutputVulkan::RenderEnd(), MythVideoOutputVulkan::RenderFrame(), MythVideoOutputOpenGL::RenderFrame(), MythOpenGLVideo::RenderFrame(), HDHRStreamHandler::run(), AvFormatDecoder::ScanStreams(), Scheduler::SchedNewRecords(), MSqlQuery::seekDebug(), AutoExpire::SendDeleteMessages(), RecorderBase::SetRingBuffer(), LiveTVChain::SwitchTo(), Transcode::TranscodeFile(), DVBChannel::Tune(), HouseKeeperTask::UpdateLastRun(), Scheduler::UpdateMatches(), MythWebSocket::Write(), MythSocket::WriteStringListReal(), and MythOpenGLPainter::~MythOpenGLPainter().

◆ resetLogging()

MBASE_PUBLIC void resetLogging ( void  )

Intended for use only by the test harness.

Definition at line 111 of file logging.cpp.

◆ logStart()

MBASE_PUBLIC void logStart ( const QString &  logfile,
bool  progress,
int  quiet,
int  facility,
LogLevel_t  level,
bool  propagate,
bool  testHarness 

Entry point to start logging for the application.

This will start up all of the threads needed.

logfileFilename of the logfile to create. Empty if no file.
progressnon-zero if progress output will be sent to the console. This squelches all messages less important than LOG_ERR on the console
quietquiet level requested (squelches all console output)
facilitySyslog facility to use. -1 to disable syslog output
levelMinimum logging level to put into the logs
propagatetrue if the logfile path needs to be propagated to child processes.
testHarnessShould always be false. Set to true when invoked by the testing code.

Definition at line 637 of file logging.cpp.

Referenced by MythCommandLineParser::ConfigureLogging().

◆ logStop()

MBASE_PUBLIC void logStop ( void  )

Entry point for stopping logging for an application.

Definition at line 669 of file logging.cpp.

Referenced by main(), MythContext::~MythContext(), and MythCoreContextPrivate::~MythCoreContextPrivate().

◆ logPropagateCalc()

MBASE_PUBLIC void logPropagateCalc ( void  )

Generate the logPropagateArgs global with the latest logging level, mask, etc to propagate to all of the mythtv programs spawned from this one.

Definition at line 572 of file logging.cpp.

Referenced by MainServer::HandleSetLogLevel(), MainServer::HandleSetVerbose(), and logStart().

◆ logPropagateQuiet()

MBASE_PUBLIC bool logPropagateQuiet ( void  )

Check if we are propagating a "--quiet".

true if –quiet is being propagated

Definition at line 619 of file logging.cpp.

Referenced by BurnMenu::doBurn(), getFileDetails(), and MythSystemLegacy::SetCommand().

◆ syslogGetFacility()

MBASE_PUBLIC int syslogGetFacility ( const QString &  facility)

◆ logLevelGet()

MBASE_PUBLIC LogLevel_t logLevelGet ( const QString &  level)

Map a log level name back to the enumerated value.

levelQString containing the log level name
Log level as enumerated type. LOG_UNKNOWN if not found.

Definition at line 746 of file logging.cpp.

Referenced by MythCommandLineParser::GetLogLevel(), Myth::GetLogs(), V2Myth::GetLogs(), MainServer::HandleSetLogLevel(), and verboseArgParse().

◆ logLevelGetName()

MBASE_PUBLIC QString logLevelGetName ( LogLevel_t  level)

Map a log level enumerated value back to the name.

levelEnumerated value of the log level
Log level name. "unknown" if not found.

Definition at line 768 of file logging.cpp.

Referenced by MythCommandLineParser::addLogging(), Myth::GetLogs(), V2Myth::GetLogs(), MainServer::HandleSetLogLevel(), logPropagateCalc(), and logStart().

◆ verboseArgParse()

MBASE_PUBLIC int verboseArgParse ( const QString &  arg)

Parse the –verbose commandline argument and set the verbose level.

argthe commandline argument following "--verbose"
an exit code. GENERIC_EXIT_OK if all is well.

Definition at line 894 of file logging.cpp.

Referenced by MythCommandLineParser::ConfigureLogging(), MainServer::HandleSetVerbose(), and NetworkControl::processSet().

◆ logStrerror()

MBASE_PUBLIC QString logStrerror ( int  errnum)

Verbose helper function for ENO macro.

errnumsystem errno value
QString containing the string version of the errno value, plus the errno value itself.

Definition at line 1023 of file logging.cpp.

Referenced by DVBChannel::DrainDVBEvents().

Variable Documentation

◆ logLevel

MBASE_PUBLIC LogLevel_t logLevel

◆ verboseMask

MBASE_PUBLIC uint64_t verboseMask

◆ componentLogLevel

Definition at line 99 of file logging.cpp.

Referenced by VERBOSE_LEVEL_CHECK(), and verboseArgParse().

◆ logPropagateArgList

MBASE_PUBLIC QStringList logPropagateArgList

Definition at line 83 of file logging.cpp.

Referenced by logPropagateCalc(), and MythSystemLegacy::SetCommand().

◆ logPropagateArgs

MBASE_PUBLIC QString logPropagateArgs

◆ verboseString

MBASE_PUBLIC QString verboseString
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
Definition: mythlogging.h:29