00001 #ifndef MYTHVERBOSE_H_
00002 #define MYTHVERBOSE_H_
00003
00004 #ifdef __cplusplus
00005 # include <qdatetime.h>
00006
00007 using namespace std;
00008 #else
00009 # ifdef HAVE_GETTIMEOFDAY
00010 # include <sys/time.h>
00011 # include <time.h>
00012 # endif
00013 #endif
00014
00015 #include "mythexp.h"
00016
00031
00032 #define VERBOSE_MAP(F) \
00033 F(VB_ALL, 0xffffffff, "all", \
00034 0, "ALL available debug output") \
00035 F(VB_MOST, 0x7ffeffff, "most", \
00036 0, "Most debug (nodatabase,notimestamp)") \
00037 F(VB_IMPORTANT, 0x00000001, "important", \
00038 0, "Errors or other very important messages") \
00039 F(VB_GENERAL, 0x00000002, "general", \
00040 1, "General info") \
00041 F(VB_RECORD, 0x00000004, "record", \
00042 1, "Recording related messages") \
00043 F(VB_PLAYBACK, 0x00000008, "playback", \
00044 1, "Playback related messages") \
00045 F(VB_CHANNEL, 0x00000010, "channel", \
00046 1, "Channel related messages") \
00047 F(VB_OSD, 0x00000020, "osd", \
00048 1, "On-Screen Display related messages") \
00049 F(VB_FILE, 0x00000040, "file", \
00050 1, "File and AutoExpire related messages") \
00051 F(VB_SCHEDULE, 0x00000080, "schedule", \
00052 1, "Scheduling related messages") \
00053 F(VB_NETWORK, 0x00000100, "network", \
00054 1, "Network protocol related messages") \
00055 F(VB_COMMFLAG, 0x00000200, "commflag", \
00056 1, "Commercial Flagging related messages") \
00057 F(VB_AUDIO, 0x00000400, "audio", \
00058 1, "Audio related messages") \
00059 F(VB_LIBAV, 0x00000800, "libav", \
00060 1, "Enables libav debugging") \
00061 F(VB_JOBQUEUE, 0x00001000, "jobqueue", \
00062 1, "JobQueue related messages") \
00063 F(VB_SIPARSER, 0x00002000, "siparser", \
00064 1, "Siparser related messages") \
00065 F(VB_EIT, 0x00004000, "eit", \
00066 1, "EIT related messages") \
00067 F(VB_VBI, 0x00008000, "vbi", \
00068 1, "VBI related messages") \
00069 F(VB_DATABASE, 0x00010000, "database", \
00070 1, "Display all SQL commands executed") \
00071 F(VB_DSMCC, 0x00020000, "dsmcc", \
00072 1, "DSMCC carousel related messages") \
00073 F(VB_MHEG, 0x00040000, "mheg", \
00074 1, "MHEG debugging messages") \
00075 F(VB_UPNP, 0x00080000, "upnp", \
00076 1, "upnp debugging messages") \
00077 F(VB_SOCKET, 0x00100000, "socket", \
00078 1, "socket debugging messages") \
00079 F(VB_XMLTV, 0x00200000, "xmltv", \
00080 1, "xmltv output and related messages") \
00081 F(VB_DVBCAM, 0x00400000, "dvbcam", \
00082 1, "DVB CAM debugging messages") \
00083 F(VB_MEDIA, 0x00800000, "media", \
00084 1, "Media Manager debugging messages") \
00085 F(VB_IDLE, 0x01000000, "idle", \
00086 1, "System idle messages") \
00087 F(VB_TIMESTAMP, 0x80000000, "timestamp", \
00088 1, "Conditional data driven messages") \
00089 F(VB_NONE, 0x00000000, "none", \
00090 0, "NO debug output")
00091
00092 enum VerboseMask
00093 {
00094 #define VERBOSE_ENUM(ARG_ENUM, ARG_VALUE, ARG_STRING, ARG_ADDITIVE, ARG_HELP)\
00095 ARG_ENUM = ARG_VALUE ,
00096 VERBOSE_MAP(VERBOSE_ENUM)
00097 VB_UNUSED_END
00098 };
00099
00102 extern MPUBLIC unsigned int print_verbose_messages;
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 #ifndef MYTHCONTEXT_H_
00115 #ifdef __cplusplus
00116 #define VERBOSE(mask,args...) \
00117 if ((print_verbose_messages & (mask)) == (mask)) \
00118 cout << QDateTime::currentDateTime() \
00119 .toString("yyyy-MM-dd hh:mm:ss.zzz") \
00120 << " " << args << endl;
00121 #else
00122 #ifdef HAVE_GETTIMEOFDAY
00123 #define VERBOSEDATE \
00124 { \
00125 struct tm *tp; \
00126 struct timeval tv; \
00127 gettimeofday(&tv, NULL); \
00128 tp = localtime(&tv.tv_sec); \
00129 printf("%4d-%02d-%02d %2d:%02d:%02d.%03d ", \
00130 1900+tp->tm_year, 1+tp->tm_mon, \
00131 tp->tm_mday, tp->tm_hour, tp->tm_min, \
00132 tp->tm_sec, tv.tv_usec/10000); \
00133 }
00134 #else
00135 #define VERBOSEDATE ;
00136 #endif
00137 #define VERBOSE(mask,args...) \
00138 if ((print_verbose_messages & (mask)) == (mask)) \
00139 { \
00140 VERBOSEDATE \
00141 printf(args); \
00142 putchar('\n'); \
00143 }
00144 #endif
00145
00146 #elif defined(DEBUG) // && MYTHCONTEXT_H_
00147
00148
00149
00150
00151
00152
00153
00154 #define VERBOSE(mask,args...) \
00155 do { \
00156 if ((print_verbose_messages & (mask)) == (mask)) \
00157 { \
00158 QDateTime dtmp = QDateTime::currentDateTime(); \
00159 QString dtime = dtmp.toString("yyyy-MM-dd hh:mm:ss.zzz"); \
00160 MythContext::verbose_mutex.lock(); \
00161 cout << dtime << " " << args << endl; \
00162 MythContext::verbose_mutex.unlock(); \
00163 } \
00164 } while (0)
00165
00166 #else // MYTHCONTEXT_H_ && !DEBUG
00167
00168
00169
00170 #define VERBOSE(mask,args...) \
00171 do { \
00172 if ((print_verbose_messages & (mask)) == (mask)) \
00173 { \
00174 QDateTime dtmp = QDateTime::currentDateTime(); \
00175 QString dtime = dtmp.toString("yyyy-MM-dd hh:mm:ss.zzz"); \
00176 ostringstream verbose_macro_tmp; \
00177 verbose_macro_tmp << dtime << " " << args; \
00178 MythContext::verbose_mutex.lock(); \
00179 cout << verbose_macro_tmp.str() << endl; \
00180 MythContext::verbose_mutex.unlock(); \
00181 } \
00182 } while (0)
00183
00184 #endif // MYTHCONTEXT_H_, DEBUG
00185
00186
00187 #ifdef __cplusplus
00189 extern MPUBLIC QString safe_eno_to_string(int errnum);
00190
00191 extern MPUBLIC QString verboseString;
00192
00193
00199 #define ENO QString("\n\t\t\teno: ") + safe_eno_to_string(errno)
00200 #endif
00201
00202
00203 #endif
00204
00205