104 changes: 4 additions & 100 deletions mythtv/libs/libmythbase/mythverbose.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,107 +8,11 @@

#include "mythbaseexp.h" // MBASE_PUBLIC , et c.
#include "mythlogging.h"

/// This MAP is for the various VERBOSITY flags, used to select which
/// messages we want printed to the console.
///
/// The 5 fields are:
/// enum
/// enum value
/// "-v" arg string
/// additive flag (explicit = 0, additive = 1)
/// help text for "-v help"
///
/// To create a new VB_* flag, this is the only piece of code you need to
/// modify, then you can start using the new flag and it will automatically be
/// processed by the parse_verbose_arg() function and help info printed when
/// "-v help" is used.

#define VERBOSE_MAP(F) \
F(VB_ALL, 0xffffffff, "all", \
0, "ALL available debug output") \
F(VB_MOST, 0x3ffeffff, "most", \
0, "Most debug (nodatabase,notimestamp,noextra)")\
F(VB_IMPORTANT, 0x00000001, "important", \
0, "Errors or other very important messages") \
F(VB_GENERAL, 0x00000002, "general", \
1, "General info") \
F(VB_RECORD, 0x00000004, "record", \
1, "Recording related messages") \
F(VB_PLAYBACK, 0x00000008, "playback", \
1, "Playback related messages") \
F(VB_CHANNEL, 0x00000010, "channel", \
1, "Channel related messages") \
F(VB_OSD, 0x00000020, "osd", \
1, "On-Screen Display related messages") \
F(VB_FILE, 0x00000040, "file", \
1, "File and AutoExpire related messages") \
F(VB_SCHEDULE, 0x00000080, "schedule", \
1, "Scheduling related messages") \
F(VB_NETWORK, 0x00000100, "network", \
1, "Network protocol related messages") \
F(VB_COMMFLAG, 0x00000200, "commflag", \
1, "Commercial detection related messages") \
F(VB_AUDIO, 0x00000400, "audio", \
1, "Audio related messages") \
F(VB_LIBAV, 0x00000800, "libav", \
1, "Enables libav debugging") \
F(VB_JOBQUEUE, 0x00001000, "jobqueue", \
1, "JobQueue related messages") \
F(VB_SIPARSER, 0x00002000, "siparser", \
1, "Siparser related messages") \
F(VB_EIT, 0x00004000, "eit", \
1, "EIT related messages") \
F(VB_VBI, 0x00008000, "vbi", \
1, "VBI related messages") \
F(VB_DATABASE, 0x00010000, "database", \
1, "Display all SQL commands executed") \
F(VB_DSMCC, 0x00020000, "dsmcc", \
1, "DSMCC carousel related messages") \
F(VB_MHEG, 0x00040000, "mheg", \
1, "MHEG debugging messages") \
F(VB_UPNP, 0x00080000, "upnp", \
1, "upnp debugging messages") \
F(VB_SOCKET, 0x00100000, "socket", \
1, "socket debugging messages") \
F(VB_XMLTV, 0x00200000, "xmltv", \
1, "xmltv output and related messages") \
F(VB_DVBCAM, 0x00400000, "dvbcam", \
1, "DVB CAM debugging messages") \
F(VB_MEDIA, 0x00800000, "media", \
1, "Media Manager debugging messages") \
F(VB_IDLE, 0x01000000, "idle", \
1, "System idle messages") \
F(VB_CHANSCAN, 0x02000000, "channelscan", \
1, "Channel Scanning messages") \
F(VB_GUI, 0x04000000, "gui", \
1, "GUI related messages") \
F(VB_SYSTEM, 0x08000000, "system", \
1, "External executable related messages") \
/* space for more flags */ \
/* space for more flags */ \
F(VB_EXTRA, 0x40000000, "extra", \
1, "More detailed messages in selected levels") \
F(VB_TIMESTAMP, 0x80000000, "timestamp", \
1, "Conditional data driven messages") \
F(VB_NONE, 0x00000000, "none", \
0, "NO debug output")

#define VERBOSE_ENUM(ARG_ENUM, ARG_VALUE, ARG_STRING, ARG_ADDITIVE, ARG_HELP)\
ARG_ENUM = ARG_VALUE ,

enum VerboseMask
{
VERBOSE_MAP(VERBOSE_ENUM)
VB_UNUSED_END // keep at end
};
#include "verbosedefs.h"

/// This global variable is set at startup with the flags
/// of the verbose messages we want to see.
extern MBASE_PUBLIC unsigned int print_verbose_messages;
#ifdef __cplusplus
extern MBASE_PUBLIC QMutex verbose_mutex;
#endif
extern MBASE_PUBLIC uint64_t print_verbose_messages;

// Helper for checking verbose flags outside of VERBOSE macro
#define VERBOSE_LEVEL_NONE (print_verbose_messages == 0)
Expand All @@ -122,10 +26,10 @@ extern MBASE_PUBLIC unsigned int print_verbose_messages;

#ifdef __cplusplus
#define VERBOSE(mask, ...) \
LogPrintQString(mask, LOG_INFO, QString(__VA_ARGS__))
LogPrintQString((uint64_t)(mask), LOG_INFO, QString(__VA_ARGS__))
#else
#define VERBOSE(mask, ...) \
LogPrint(mask, LOG_INFO, __VA_ARGS__)
LogPrint((uint64_t)(mask), LOG_INFO, __VA_ARGS__)
#endif


Expand Down
119 changes: 119 additions & 0 deletions mythtv/libs/libmythbase/verbosedefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#ifndef VERBOSEDEFS_H_
#define VERBOSEDEFS_H_

#include <stdint.h>

/// This file gets included in two different ways:
/// 1) from mythverbose.h from nearly every file. This will define the
/// VerboseMask enum
/// 2) specifically (and a second include with _IMPLEMENT_VERBOSE defined) from
/// mythverbose.cpp. This is done in verboseInit (in the middle of the
/// function) as it will expand out to a series of calls to verboseAdd()
/// to fill the verboseMap.
///
/// The 4 fields are:
/// enum name (expected to start with VB_)
/// enum value (will be used as a 64-bit unsigned int)
/// additive flag (explicit = false, additive = true)
/// help text for "-v help"
///
/// To create a new VB_* flag, this is the only piece of code you need to
/// modify, then you can start using the new flag and it will automatically be
/// processed by the parse_verbose_arg() function and help info printed when
/// "-v help" is used.

#undef VERBOSE_PREAMBLE
#undef VERBOSE_POSTAMBLE
#undef VERBOSE_MAP

#ifdef _IMPLEMENT_VERBOSE

// This is used to actually implement the mask in mythverbose.cpp
#define VERBOSE_PREAMBLE
#define VERBOSE_POSTAMBLE
#define VERBOSE_MAP(name,mask,additive,help) \
verboseAdd((uint64_t)(mask),QString(#name),(bool)(additive),QString(help));

#else // !defined(_IMPLEMENT_VERBOSE)

// This is used to define the enumerated type (used by all files)
#define VERBOSE_PREAMBLE \
enum VerboseMask {
#define VERBOSE_POSTAMBLE \
VB_LAST_ITEM \
};
#define VERBOSE_MAP(name,mask,additive,help) \
name = (uint64_t)(mask),

#endif

VERBOSE_PREAMBLE
VERBOSE_MAP(VB_ALL, 0xffffffff, false,
"ALL available debug output")
VERBOSE_MAP(VB_MOST, 0x3ffeffff, false,
"Most debug (nodatabase,notimestamp,noextra)")
VERBOSE_MAP(VB_IMPORTANT, 0x00000001, false,
"Errors or other very important messages")
VERBOSE_MAP(VB_GENERAL, 0x00000002, true,
"General info")
VERBOSE_MAP(VB_RECORD, 0x00000004, true,
"Recording related messages")
VERBOSE_MAP(VB_PLAYBACK, 0x00000008, true,
"Playback related messages")
VERBOSE_MAP(VB_CHANNEL, 0x00000010, true,
"Channel related messages")
VERBOSE_MAP(VB_OSD, 0x00000020, true,
"On-Screen Display related messages")
VERBOSE_MAP(VB_FILE, 0x00000040, true,
"File and AutoExpire related messages")
VERBOSE_MAP(VB_SCHEDULE, 0x00000080, true,
"Scheduling related messages")
VERBOSE_MAP(VB_NETWORK, 0x00000100, true,
"Network protocol related messages")
VERBOSE_MAP(VB_COMMFLAG, 0x00000200, true,
"Commercial detection related messages")
VERBOSE_MAP(VB_AUDIO, 0x00000400, true,
"Audio related messages")
VERBOSE_MAP(VB_LIBAV, 0x00000800, true,
"Enables libav debugging")
VERBOSE_MAP(VB_JOBQUEUE, 0x00001000, true,
"JobQueue related messages")
VERBOSE_MAP(VB_SIPARSER, 0x00002000, true,
"Siparser related messages")
VERBOSE_MAP(VB_EIT, 0x00004000, true,
"EIT related messages")
VERBOSE_MAP(VB_VBI, 0x00008000, true,
"VBI related messages")
VERBOSE_MAP(VB_DATABASE, 0x00010000, true,
"Display all SQL commands executed")
VERBOSE_MAP(VB_DSMCC, 0x00020000, true,
"DSMCC carousel related messages")
VERBOSE_MAP(VB_MHEG, 0x00040000, true,
"MHEG debugging messages")
VERBOSE_MAP(VB_UPNP, 0x00080000, true,
"UPnP debugging messages")
VERBOSE_MAP(VB_SOCKET, 0x00100000, true,
"socket debugging messages")
VERBOSE_MAP(VB_XMLTV, 0x00200000, true,
"xmltv output and related messages")
VERBOSE_MAP(VB_DVBCAM, 0x00400000, true,
"DVB CAM debugging messages")
VERBOSE_MAP(VB_MEDIA, 0x00800000, true,
"Media Manager debugging messages")
VERBOSE_MAP(VB_IDLE, 0x01000000, true,
"System idle messages")
VERBOSE_MAP(VB_CHANSCAN, 0x02000000, true,
"Channel Scanning messages")
VERBOSE_MAP(VB_GUI, 0x04000000, true,
"GUI related messages")
VERBOSE_MAP(VB_SYSTEM, 0x08000000, true,
"External executable related messages")
VERBOSE_MAP(VB_EXTRA, 0x40000000, true,
"More detailed messages in selected levels")
VERBOSE_MAP(VB_TIMESTAMP, 0x80000000, true,
"Conditional data driven messages")
VERBOSE_MAP(VB_NONE, 0x00000000, false,
"NO debug output")
VERBOSE_POSTAMBLE

#endif