MythTV
master
|
#include <QtGlobal>
#include <QAtomicInt>
#include <QMutex>
#include <QMutexLocker>
#include <QWaitCondition>
#include <QList>
#include <QQueue>
#include <QHash>
#include <QFileInfo>
#include <QStringList>
#include <QMap>
#include <QRegularExpression>
#include <QVariantMap>
#include <iostream>
#include "mythlogging.h"
#include "logging.h"
#include "loggingserver.h"
#include "mythdb.h"
#include "mythdirs.h"
#include "mythcorecontext.h"
#include "mythsystemlegacy.h"
#include "dbutil.h"
#include "exitcodes.h"
#include "compat.h"
#include <csignal>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <utility>
#include <unistd.h>
#include "verbosedefs.h"
Go to the source code of this file.
Classes | |
struct | LogPropagateOpts |
Macros | |
#define | SYSLOG_NAMES |
#define | MYTH_IMPLEMENT_VERBOSE |
Functions | |
void | verboseAdd (uint64_t mask, QString name, bool additive, QString helptext) |
Add a verbose level to the verboseMap. More... | |
void | loglevelAdd (int value, QString name, char shortname) |
Add a log level to the logLevelMap. More... | |
void | verboseInit (void) |
Initialize the logging levels and verbose levels. More... | |
void | verboseHelp (void) |
Outputs the Verbose levels and their descriptions (for –verbose help) More... | |
void | resetLogging (void) |
Intended for use only by the test harness. More... | |
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... | |
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... | |
bool | logPropagateQuiet (void) |
Check if we are propagating a "--quiet". More... | |
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. More... | |
void | logStop (void) |
Entry point for stopping logging for an application. More... | |
void | loggingRegisterThread (const QString &name) |
Register the current thread with the given name. More... | |
void | loggingDeregisterThread (void) |
Deregister the current thread's name. More... | |
int | syslogGetFacility (const QString &facility) |
Map a syslog facility name back to the enumerated value. More... | |
LogLevel_t | logLevelGet (const QString &level) |
Map a log level name back to the enumerated value. More... | |
QString | logLevelGetName (LogLevel_t level) |
Map a log level enumerated value back to the name. More... | |
int | verboseArgParse (const QString &arg) |
Parse the –verbose commandline argument and set the verbose level. More... | |
QString | logStrerror (int errnum) |
Verbose helper function for ENO macro. More... | |
Variables | |
static QMutex | logQueueMutex |
static QQueue< LoggingItem * > | logQueue |
static LoggerThread * | logThread = nullptr |
static QMutex | logThreadMutex |
static QHash< uint64_t, QString > | logThreadHash |
static QMutex | logThreadTidMutex |
static QHash< uint64_t, int64_t > | logThreadTidHash |
static bool | logThreadFinished = false |
static bool | debugRegistration = false |
LogPropagateOpts | logPropagateOpts {false, 0, 0, ""} |
QString | logPropagateArgs |
QStringList | logPropagateArgList |
LogLevel_t | logLevel = LOG_INFO |
bool | verboseInitialized = false |
VerboseMap | verboseMap |
QMutex | verboseMapMutex |
LoglevelMap | loglevelMap |
QMutex | loglevelMapMutex |
const uint64_t | verboseDefaultInt = VB_GENERAL |
const QString | verboseDefaultStr { QStringLiteral(" general") } |
uint64_t | verboseMask = verboseDefaultInt |
QString | verboseString = verboseDefaultStr |
ComponentLogLevelMap | componentLogLevel |
uint64_t | userDefaultValueInt = verboseDefaultInt |
QString | userDefaultValueStr = verboseDefaultStr |
bool | haveUserDefaultValues = false |
#define SYSLOG_NAMES |
Definition at line 39 of file logging.cpp.
#define MYTH_IMPLEMENT_VERBOSE |
void verboseAdd | ( | uint64_t | mask, |
QString | name, | ||
bool | additive, | ||
QString | helptext | ||
) |
Add a verbose level to the verboseMap.
Done at initialization.
mask | verbose mask (VB_*) |
name | name of the verbosity level |
additive | true if this is to be ORed with other masks. false if is will clear the other bits. |
helptext | Descriptive text for –verbose help output |
Definition at line 794 of file logging.cpp.
void loglevelAdd | ( | int | value, |
QString | name, | ||
char | shortname | ||
) |
Add a log level to the logLevelMap.
Done at initialization.
value | log level enumerated value (LOG_*) - matches syslog levels |
name | name of the log level |
shortname | one-letter short name for output into logs |
Definition at line 814 of file logging.cpp.
void verboseInit | ( | void | ) |
Initialize the logging levels and verbose levels.
Definition at line 829 of file logging.cpp.
Referenced by logLevelGet(), logLevelGetName(), resetLogging(), and verboseArgParse().
void verboseHelp | ( | void | ) |
Outputs the Verbose levels and their descriptions (for –verbose help)
Definition at line 854 of file logging.cpp.
Referenced by verboseArgParse().
void resetLogging | ( | void | ) |
Intended for use only by the test harness.
Definition at line 111 of file logging.cpp.
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.
mask | Verbosity mask of the message (VB_*) |
level | Log level of this message (LOG_* - matching syslog levels) |
file | Filename of source code logging the message |
line | Line number within the source of log message source |
function | Function name of the log message source |
message | log message |
Definition at line 529 of file logging.cpp.
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 573 of file logging.cpp.
Referenced by MainServer::HandleSetLogLevel(), MainServer::HandleSetVerbose(), and logStart().
bool logPropagateQuiet | ( | void | ) |
Check if we are propagating a "--quiet".
Definition at line 620 of file logging.cpp.
Referenced by BurnMenu::doBurn(), getFileDetails(), and MythSystemLegacy::SetCommand().
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.
logfile | Filename of the logfile to create. Empty if no file. |
progress | non-zero if progress output will be sent to the console. This squelches all messages less important than LOG_ERR on the console |
quiet | quiet level requested (squelches all console output) |
facility | Syslog facility to use. -1 to disable syslog output |
level | Minimum logging level to put into the logs |
propagate | true if the logfile path needs to be propagated to child processes. |
testHarness | Should always be false. Set to true when invoked by the testing code. |
Definition at line 638 of file logging.cpp.
Referenced by MythCommandLineParser::ConfigureLogging().
void logStop | ( | void | ) |
Entry point for stopping logging for an application.
Definition at line 670 of file logging.cpp.
Referenced by main(), MythContext::~MythContext(), and MythCoreContextPrivate::~MythCoreContextPrivate().
void loggingRegisterThread | ( | const QString & | name | ) |
Register the current thread with the given name.
This is triggered by the RunProlog() call in each thread.
name | the name of the thread being registered. This is used for indicating the thread each log message is coming from. |
Definition at line 685 of file logging.cpp.
Referenced by MPoolThread::run(), and MThread::ThreadSetup().
void loggingDeregisterThread | ( | void | ) |
Deregister the current thread's name.
This is triggered by the RunEpilog() call in each thread.
Definition at line 704 of file logging.cpp.
Referenced by MPoolThread::run(), MThread::ThreadCleanup(), and MythCoreContextPrivate::~MythCoreContextPrivate().
int syslogGetFacility | ( | const QString & | facility | ) |
Map a syslog facility name back to the enumerated value.
facility | QString containing the facility name |
Definition at line 722 of file logging.cpp.
Referenced by MythCommandLineParser::GetSyslogFacility().
LogLevel_t logLevelGet | ( | const QString & | level | ) |
Map a log level name back to the enumerated value.
level | QString containing the log level name |
Definition at line 749 of file logging.cpp.
Referenced by MythCommandLineParser::GetLogLevel(), Myth::GetLogs(), V2Myth::GetLogs(), MainServer::HandleSetLogLevel(), and verboseArgParse().
QString logLevelGetName | ( | LogLevel_t | level | ) |
Map a log level enumerated value back to the name.
level | Enumerated value of the log level |
Definition at line 771 of file logging.cpp.
Referenced by MythCommandLineParser::addLogging(), Myth::GetLogs(), V2Myth::GetLogs(), MainServer::HandleSetLogLevel(), logPropagateCalc(), and logStart().
int verboseArgParse | ( | const QString & | arg | ) |
Parse the –verbose commandline argument and set the verbose level.
arg | the commandline argument following "--verbose" |
Definition at line 897 of file logging.cpp.
Referenced by MythCommandLineParser::ConfigureLogging(), MainServer::HandleSetVerbose(), and NetworkControl::processSet().
QString logStrerror | ( | int | errnum | ) |
Verbose helper function for ENO macro.
errnum | system errno value |
Definition at line 1026 of file logging.cpp.
Referenced by DVBChannel::DrainDVBEvents().
|
static |
Definition at line 61 of file logging.cpp.
Referenced by LoggerThread::flush(), loggingDeregisterThread(), loggingRegisterThread(), LogPrintLine(), LoggerThread::run(), and LoggerThread::stop().
|
static |
Definition at line 62 of file logging.cpp.
Referenced by LoggerThread::flush(), loggingDeregisterThread(), loggingRegisterThread(), LogPrintLine(), and LoggerThread::run().
|
static |
Definition at line 64 of file logging.cpp.
Referenced by LogPrintLine(), logStart(), and logStop().
|
static |
Definition at line 65 of file logging.cpp.
Referenced by LoggingItem::getThreadName(), and LoggerThread::handleItem().
|
static |
Definition at line 66 of file logging.cpp.
Referenced by LoggingItem::getThreadName(), and LoggerThread::handleItem().
|
static |
Definition at line 68 of file logging.cpp.
Referenced by LoggingItem::getThreadTid(), LoggerThread::handleItem(), and LoggingItem::setThreadTid().
|
static |
Definition at line 69 of file logging.cpp.
Referenced by LoggingItem::getThreadTid(), LoggerThread::handleItem(), and LoggingItem::setThreadTid().
Definition at line 71 of file logging.cpp.
Referenced by loggingDeregisterThread(), loggingRegisterThread(), LogPrintLine(), and LoggerThread::run().
Definition at line 72 of file logging.cpp.
Referenced by LoggerThread::handleItem(), and LoggerThread::LoggerThread().
LogPropagateOpts logPropagateOpts {false, 0, 0, ""} |
Definition at line 81 of file logging.cpp.
Referenced by logPropagateCalc(), logPropagateQuiet(), and logStart().
QString logPropagateArgs |
Definition at line 82 of file logging.cpp.
Referenced by WelcomeDialog::checkAutoStart(), BurnMenu::doBurn(), JobQueue::DoFlagCommercialsThread(), JobQueue::DoMetadataLookupThread(), RadioStreamUpdateTask::DoRun(), ArtworkTask::DoRun(), JobQueue::DoTranscodeThread(), ExternalStreamHandler::ExternalStreamHandler(), Myth::GetBackendInfo(), V2Myth::GetBackendInfo(), getFileDetails(), JobQueue::GetJobCommand(), WelcomeDialog::keyPressEvent(), WelcomeDialog::lockShutdown(), logPropagateCalc(), main(), HTTPLiveStreamThread::run(), WelcomeDialog::runMythFillDatabase(), MythSystemLegacy::SetCommand(), WelcomeDialog::ShowMenu(), WelcomeDialog::shutdownNow(), LCD::startLCDServer(), MythSystemEventHandler::SubstituteMatches(), WelcomeDialog::unlockShutdown(), SourceUtil::UpdateChannelsFromListings(), and WelcomeDialog::updateStatusMessage().
QStringList logPropagateArgList |
Definition at line 83 of file logging.cpp.
Referenced by logPropagateCalc(), and MythSystemLegacy::SetCommand().
LogLevel_t logLevel = LOG_INFO |
Definition at line 85 of file logging.cpp.
Referenced by handle_command(), MainServer::HandleSetLogLevel(), logPropagateCalc(), logStart(), main(), MHSetLogging(), PrintOutput::Output(), pid_counter(), pid_filter(), pid_printer(), MythSocket::ReadStringListReal(), VERBOSE_LEVEL_CHECK(), and MythSocket::WriteStringListReal().
Definition at line 87 of file logging.cpp.
Referenced by logLevelGet(), logLevelGetName(), verboseArgParse(), and verboseInit().
VerboseMap verboseMap |
Definition at line 88 of file logging.cpp.
Referenced by verboseAdd(), verboseArgParse(), verboseHelp(), and verboseInit().
QMutex verboseMapMutex |
Definition at line 89 of file logging.cpp.
Referenced by verboseArgParse(), and verboseInit().
LoglevelMap loglevelMap |
Definition at line 91 of file logging.cpp.
Referenced by LoggingItem::getLevelChar(), loglevelAdd(), logLevelGet(), logLevelGetName(), and verboseInit().
QMutex loglevelMapMutex |
Definition at line 92 of file logging.cpp.
Referenced by LoggingItem::getLevelChar(), logLevelGet(), logLevelGetName(), and verboseInit().
const uint64_t verboseDefaultInt = VB_GENERAL |
Definition at line 94 of file logging.cpp.
Referenced by resetLogging(), and verboseArgParse().
const QString verboseDefaultStr { QStringLiteral(" general") } |
Definition at line 95 of file logging.cpp.
Referenced by resetLogging(), and verboseArgParse().
uint64_t verboseMask = verboseDefaultInt |
Definition at line 97 of file logging.cpp.
Referenced by MythCommandLineParser::ConfigureLogging(), JobQueue::GetJobCommand(), handle_command(), main(), resetLogging(), MythSystemEventHandler::SubstituteMatches(), VERBOSE_LEVEL_CHECK(), VERBOSE_LEVEL_NONE(), and verboseArgParse().
QString verboseString = verboseDefaultStr |
Definition at line 98 of file logging.cpp.
Referenced by MythCommandLineParser::ConfigureLogging(), MainServer::HandleSetVerbose(), logPropagateCalc(), main(), NetworkControl::processQuery(), NetworkControl::processSet(), resetLogging(), and verboseArgParse().
ComponentLogLevelMap componentLogLevel |
Definition at line 99 of file logging.cpp.
Referenced by VERBOSE_LEVEL_CHECK(), and verboseArgParse().
uint64_t userDefaultValueInt = verboseDefaultInt |
Definition at line 101 of file logging.cpp.
Referenced by resetLogging(), and verboseArgParse().
QString userDefaultValueStr = verboseDefaultStr |
Definition at line 102 of file logging.cpp.
Referenced by resetLogging(), verboseArgParse(), and verboseHelp().
Definition at line 103 of file logging.cpp.
Referenced by resetLogging(), and verboseArgParse().