Skip to content

Commit

Permalink
tidy: Converty the VERBOSE_LEVEL macros to inline functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdude42 committed Jul 10, 2022
1 parent ec27545 commit c1ea14a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion mythplugins/mythmusic/mythmusic/avfdecoder.cpp
Expand Up @@ -172,7 +172,7 @@ ShoutCastMetaMap ShoutCastMetaParser::parseMeta(const QString &mdata)

static void myth_av_log(void *ptr, int level, const char* fmt, va_list vl)
{
if (VERBOSE_LEVEL_NONE)
if (VERBOSE_LEVEL_NONE())
return;

static QString s_fullLine("");
Expand Down
42 changes: 21 additions & 21 deletions mythtv/libs/libmythbase/mythlogging.h
Expand Up @@ -9,27 +9,6 @@
#include "mythbaseexp.h" // MBASE_PUBLIC , etc.
#include "verbosedefs.h"

// Helper for checking verbose mask & level outside of LOG macro
#define VERBOSE_LEVEL_NONE (verboseMask == 0)
#define VERBOSE_LEVEL_CHECK(_MASK_, _LEVEL_) \
(componentLogLevel.contains(_MASK_) ? \
(*(componentLogLevel.find(_MASK_)) >= (_LEVEL_)) : \
(((verboseMask & (_MASK_)) == (_MASK_)) && logLevel >= (_LEVEL_)))

#define VERBOSE please_use_LOG_instead_of_VERBOSE

// This doesn't lock the calling thread other than momentarily to put
// the log message onto a queue.
#define LOG(_MASK_, _LEVEL_, _QSTRING_) \
do { \
if (VERBOSE_LEVEL_CHECK((_MASK_), (_LEVEL_)) && ((_LEVEL_)>=0)) \
{ \
LogPrintLine(_MASK_, _LEVEL_, \
__FILE__, __LINE__, __FUNCTION__, \
_QSTRING_); \
} \
} while (false)

/* Define the external prototype */
MBASE_PUBLIC void LogPrintLine( uint64_t mask, LogLevel_t level,
const char *file, int line,
Expand All @@ -45,6 +24,27 @@ extern MBASE_PUBLIC QStringList logPropagateArgList;
extern MBASE_PUBLIC QString logPropagateArgs;
extern MBASE_PUBLIC QString verboseString;

// Helper for checking verbose mask & level outside of LOG macro
static inline bool VERBOSE_LEVEL_NONE() { return verboseMask == 0; };
static inline bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
{
if (componentLogLevel.contains(mask))
return *(componentLogLevel.find(mask)) >= level;
return (((verboseMask & mask) == mask) && (logLevel >= level));
}

// This doesn't lock the calling thread other than momentarily to put
// the log message onto a queue.
#define LOG(_MASK_, _LEVEL_, _QSTRING_) \
do { \
if (VERBOSE_LEVEL_CHECK((_MASK_), (_LEVEL_)) && ((_LEVEL_)>=0)) \
{ \
LogPrintLine(_MASK_, _LEVEL_, \
__FILE__, __LINE__, __FUNCTION__, \
_QSTRING_); \
} \
} while (false)

MBASE_PUBLIC void resetLogging(void);

MBASE_PUBLIC void logStart(const QString& logfile, bool progress = false,
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/channelscan/channelscanner_cli.cpp
Expand Up @@ -88,7 +88,7 @@ void ChannelScannerCLI::HandleEvent(const ScannerEvent *scanEvent)

//cout<<"HERE<"<<verboseMask<<">"<<endl;
QString msg;
if (VERBOSE_LEVEL_NONE || VERBOSE_LEVEL_CHECK(VB_CHANSCAN, LOG_INFO))
if (VERBOSE_LEVEL_NONE() || VERBOSE_LEVEL_CHECK(VB_CHANSCAN, LOG_INFO))
{
msg = QString("%1% S/N %2 %3 : %4 (%5) %6")
.arg(m_statusComplete, 3)
Expand All @@ -109,7 +109,7 @@ void ChannelScannerCLI::HandleEvent(const ScannerEvent *scanEvent)
s_oldMsg = msg;
}
}
else if (VERBOSE_LEVEL_NONE)
else if (VERBOSE_LEVEL_NONE())
{
if (msg.length() > 80)
msg = msg.left(77) + "...";
Expand All @@ -120,7 +120,7 @@ void ChannelScannerCLI::HandleEvent(const ScannerEvent *scanEvent)

void ChannelScannerCLI::InformUser(const QString &error)
{
if (VERBOSE_LEVEL_NONE)
if (VERBOSE_LEVEL_NONE())
{
std::cerr<<"ERROR: "<<error.toLatin1().constData()<<std::endl;
}
Expand All @@ -145,6 +145,6 @@ void ChannelScannerCLI::Process(const ScanDTVTransportList &_transports)
void ChannelScannerCLI::MonitorProgress(
bool /*lock*/, bool /*strength*/, bool /*snr*/, bool /*rotor*/)
{
if (VERBOSE_LEVEL_NONE)
if (VERBOSE_LEVEL_NONE())
std::cout<<"\r0%"<<std::flush;
}
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Expand Up @@ -264,7 +264,7 @@ static void myth_av_log(void *ptr, int level, const char* fmt, va_list vl)
if (silence_ffmpeg_logging)
return;

if (VERBOSE_LEVEL_NONE)
if (VERBOSE_LEVEL_NONE())
return;

static QString s_fullLine("");
Expand Down

0 comments on commit c1ea14a

Please sign in to comment.