| 1 | extern unsigned int print_verbose_messages; |
| 2 | |
| 3 | /// This MAP is for the various VERBOSITY flags, used to select which |
| 4 | /// messages we want printed to the console. |
| 5 | /// |
| 6 | /// The 5 fields are: |
| 7 | /// enum |
| 8 | /// enum value |
| 9 | /// "-v" arg string |
| 10 | /// additive flag (explicit = 0, additive = 1) |
| 11 | /// help text for "-v help" |
| 12 | /// |
| 13 | /// To create a new VB_* flag, this is the only piece of code you need to |
| 14 | /// modify, then you can start using the new flag and it will automatically be |
| 15 | /// processed by the parse_verbose_arg() function and help info printed when |
| 16 | /// "-v help" is used. |
| 17 | |
| 18 | #define VERBOSE_MAP(F) \ |
| 19 | F(VB_ALL, 0xffffffff, "all", 0, \ |
| 20 | "ALL available debug output") \ |
| 21 | F(VB_IMPORTANT, 0x00000001, "important", 0, \ |
| 22 | "Errors or other very important messages") \ |
| 23 | F(VB_GENERAL, 0x00000002, "general", 1, \ |
| 24 | "General info") \ |
| 25 | F(VB_RECORD, 0x00000004, "record", 1, \ |
| 26 | "Recording related messages") \ |
| 27 | F(VB_PLAYBACK, 0x00000008, "playback", 1, \ |
| 28 | "Playback related messages") \ |
| 29 | F(VB_CHANNEL, 0x00000010, "channel", 1, \ |
| 30 | "Channel related messages") \ |
| 31 | F(VB_OSD, 0x00000020, "osd", 1, \ |
| 32 | "On-Screen Display related messages") \ |
| 33 | F(VB_FILE, 0x00000040, "file", 1, \ |
| 34 | "File and AutoExpire related messages") \ |
| 35 | F(VB_SCHEDULE, 0x00000080, "schedule", 1, \ |
| 36 | "Scheduling related messages") \ |
| 37 | F(VB_NETWORK, 0x00000100, "network", 1, \ |
| 38 | "Network protocol related messages") \ |
| 39 | F(VB_COMMFLAG, 0x00000200, "commflag", 1, \ |
| 40 | "Commercial Flagging related messages") \ |
| 41 | F(VB_AUDIO, 0x00000400, "audio", 1, \ |
| 42 | "Audio related messages") \ |
| 43 | F(VB_LIBAV, 0x00000800, "libav", 1, \ |
| 44 | "Enables libav debugging") \ |
| 45 | F(VB_JOBQUEUE, 0x00001000, "jobqueue", 1, \ |
| 46 | "JobQueue related messages") \ |
| 47 | F(VB_SIPARSER, 0x00002000, "siparser", 1, \ |
| 48 | "Siparser related messages") \ |
| 49 | F(VB_EIT, 0x00004000, "eit", 1, \ |
| 50 | "EIT related messages") \ |
| 51 | F(VB_VBI, 0x00008000, "vbi", 1, \ |
| 52 | "VBI related messages") \ |
| 53 | F(VB_DATABASE, 0x00010000, "database", 1, \ |
| 54 | "Display all SQL commands executed") \ |
| 55 | F(VB_DSMCC, 0x00020000, "dsmcc", 1, \ |
| 56 | "DSMCC carousel related messages") \ |
| 57 | F(VB_MHEG, 0x00040000, "mheg", 1, \ |
| 58 | "MHEG debugging messages") \ |
| 59 | F(VB_UPNP, 0x00080000, "upnp", 1, \ |
| 60 | "upnp debugging messages") \ |
| 61 | F(VB_SOCKET, 0x00100000, "socket", 1, \ |
| 62 | "socket debugging messages") \ |
| 63 | F(VB_TIMESTAMP, 0x80000000, "timestamp", 1, \ |
| 64 | "Conditional data driven messages") \ |
| 65 | F(VB_NONE, 0x00000000, "none", 0, \ |
| 66 | "NO debug output") |
| 67 | |
| 68 | enum VerboseMask |
| 69 | { |
| 70 | #define VERBOSE_ENUM(ARG_ENUM, ARG_VALUE, ARG_STRING, ARG_ADDITIVE, ARG_HELP)\ |
| 71 | ARG_ENUM = ARG_VALUE , |
| 72 | VERBOSE_MAP(VERBOSE_ENUM) |
| 73 | }; |
| 74 | |
| 75 | #define VERBOSE(mask,args...) \ |
| 76 | do { \ |
| 77 | if ( (print_verbose_messages&(mask)) == (mask)) \ |
| 78 | { \ |
| 79 | char _pbuf[256]; \ |
| 80 | struct tm *_tp; \ |
| 81 | struct timeval _tv; \ |
| 82 | \ |
| 83 | gettimeofday(&_tv,NULL); \ |
| 84 | _tp = localtime(&_tv.tv_sec); \ |
| 85 | snprintf(_pbuf,sizeof(_pbuf),args ); \ |
| 86 | printf("%4d-%02d-%02d %2d:%02d:%02d.%03d " __FILE__ ": %s\n",1900+_tp->tm_year,1+_tp->tm_mon,_tp->tm_mday,_tp->tm_hour,_tp->tm_min,_tp->tm_sec,_tv.tv_usec/10000,_pbuf); \ |
| 87 | }\ |
| 88 | } while (0) |