1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 12:10:03 +00:00

Add debugging output at runtime

The new command line option '-D' ('--debug') increases debugging level by one.
For debugging output a user could be interested in, use the macros DEBUG() and
DEBUG2(). Functionality is equal to the ERR() macro. DEBUG2() prints stuff only
if debugging level is greater one, which means that '--debug' has been
specified more than once. This patch also includes usage of the macros for the
new template object (as debugging syntax errors in templates is one thing a
user potentially needs to do).


git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1273 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Phil 2008-11-30 20:53:20 +00:00
parent a89bef1b0e
commit c4b98f0762
3 changed files with 26 additions and 8 deletions

View File

@ -1,5 +1,8 @@
# $Id$
2008-11-30
* Added runtime debugging output
2008-11-29
* Added template support

View File

@ -73,6 +73,9 @@
//#define SIGNAL_BLOCKING
#undef SIGNAL_BLOCKING
/* debugging level */
int global_debug_level = 0;
static void print_version(void) __attribute__((noreturn));
static void print_version(void)
@ -4366,9 +4369,7 @@ static int handle_template_object(struct text_object_list **list,
for (i = 0; i < argcnt; i++) {
char *tmp;
tmp = backslash_escape(argsp[i], NULL, 0);
#if 0
printf("%s: substituted arg '%s' to '%s'\n", tmpl, argsp[i], tmp);
#endif
DEBUG2("%s: substituted arg '%s' to '%s'", tmpl, argsp[i], tmp);
sprintf(argsp[i], "%s", tmp);
free(tmp);
}
@ -4376,9 +4377,8 @@ static int handle_template_object(struct text_object_list **list,
p = template_dup = strdup(template[template_idx]);
eval_text = backslash_escape(template[template_idx], argsp, argcnt);
#if 0
printf("substituted %s, output is '%s'\n", tmpl, eval_text);
#endif
DEBUG("substituted %s, output is '%s'", tmpl, eval_text);
eval_list = extract_variable_text_internal(eval_text, allow_threaded);
if (eval_list) {
(*list)->text_objects = realloc((*list)->text_objects,
@ -9142,6 +9142,7 @@ static void print_help(const char *prog_name) {
"file.\n"
" -v, --version version\n"
" -q, --quiet quiet mode\n"
" -D, --debug increase debugging output\n"
" -c, --config=FILE config file to load\n"
" -d, --daemonize daemonize, fork to background\n"
" -h, --help help\n"
@ -9166,7 +9167,7 @@ static void print_help(const char *prog_name) {
}
/* : means that character before that takes an argument */
static const char *getopt_string = "vVqdt:u:i:hc:"
static const char *getopt_string = "vVqdDt:u:i:hc:"
#ifdef X11
"x:y:w:a:f:"
#ifdef OWN_WINDOW
@ -9181,6 +9182,7 @@ static const char *getopt_string = "vVqdt:u:i:hc:"
static const struct option longopts[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
{ "debug", 0, NULL, 'D' },
{ "config", 1, NULL, 'c' },
{ "daemonize", 0, NULL, 'd' },
#ifdef X11
@ -9360,7 +9362,9 @@ int main(int argc, char **argv)
case 'd':
fork_to_background = 1;
break;
case 'D':
global_debug_level++;
break;
#ifdef X11
case 'f':
set_first_font(optarg);

View File

@ -117,6 +117,17 @@ extern unsigned int text_buffer_size;
#define CRIT_ERR(...) \
{ ERR(__VA_ARGS__); exit(EXIT_FAILURE); }
/* debugging output */
extern int global_debug_level;
#define __DBG(level, ...) \
if (global_debug_level > level) { \
fprintf(stderr, "DEBUG(%d): ", level); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
}
#define DEBUG(...) __DBG(0, __VA_ARGS__)
#define DEBUG2(...) __DBG(1, __VA_ARGS__)
struct net_stat {
const char *dev;
int up;