mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 12:27:52 +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:
parent
a89bef1b0e
commit
c4b98f0762
@ -1,5 +1,8 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
2008-11-30
|
||||||
|
* Added runtime debugging output
|
||||||
|
|
||||||
2008-11-29
|
2008-11-29
|
||||||
* Added template support
|
* Added template support
|
||||||
|
|
||||||
|
20
src/conky.c
20
src/conky.c
@ -73,6 +73,9 @@
|
|||||||
//#define SIGNAL_BLOCKING
|
//#define SIGNAL_BLOCKING
|
||||||
#undef SIGNAL_BLOCKING
|
#undef SIGNAL_BLOCKING
|
||||||
|
|
||||||
|
/* debugging level */
|
||||||
|
int global_debug_level = 0;
|
||||||
|
|
||||||
static void print_version(void) __attribute__((noreturn));
|
static void print_version(void) __attribute__((noreturn));
|
||||||
|
|
||||||
static void print_version(void)
|
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++) {
|
for (i = 0; i < argcnt; i++) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
tmp = backslash_escape(argsp[i], NULL, 0);
|
tmp = backslash_escape(argsp[i], NULL, 0);
|
||||||
#if 0
|
DEBUG2("%s: substituted arg '%s' to '%s'", tmpl, argsp[i], tmp);
|
||||||
printf("%s: substituted arg '%s' to '%s'\n", tmpl, argsp[i], tmp);
|
|
||||||
#endif
|
|
||||||
sprintf(argsp[i], "%s", tmp);
|
sprintf(argsp[i], "%s", tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
@ -4376,9 +4377,8 @@ static int handle_template_object(struct text_object_list **list,
|
|||||||
p = template_dup = strdup(template[template_idx]);
|
p = template_dup = strdup(template[template_idx]);
|
||||||
|
|
||||||
eval_text = backslash_escape(template[template_idx], argsp, argcnt);
|
eval_text = backslash_escape(template[template_idx], argsp, argcnt);
|
||||||
#if 0
|
DEBUG("substituted %s, output is '%s'", tmpl, eval_text);
|
||||||
printf("substituted %s, output is '%s'\n", tmpl, eval_text);
|
|
||||||
#endif
|
|
||||||
eval_list = extract_variable_text_internal(eval_text, allow_threaded);
|
eval_list = extract_variable_text_internal(eval_text, allow_threaded);
|
||||||
if (eval_list) {
|
if (eval_list) {
|
||||||
(*list)->text_objects = realloc((*list)->text_objects,
|
(*list)->text_objects = realloc((*list)->text_objects,
|
||||||
@ -9142,6 +9142,7 @@ static void print_help(const char *prog_name) {
|
|||||||
"file.\n"
|
"file.\n"
|
||||||
" -v, --version version\n"
|
" -v, --version version\n"
|
||||||
" -q, --quiet quiet mode\n"
|
" -q, --quiet quiet mode\n"
|
||||||
|
" -D, --debug increase debugging output\n"
|
||||||
" -c, --config=FILE config file to load\n"
|
" -c, --config=FILE config file to load\n"
|
||||||
" -d, --daemonize daemonize, fork to background\n"
|
" -d, --daemonize daemonize, fork to background\n"
|
||||||
" -h, --help help\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 */
|
/* : 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
|
#ifdef X11
|
||||||
"x:y:w:a:f:"
|
"x:y:w:a:f:"
|
||||||
#ifdef OWN_WINDOW
|
#ifdef OWN_WINDOW
|
||||||
@ -9181,6 +9182,7 @@ static const char *getopt_string = "vVqdt:u:i:hc:"
|
|||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
{ "version", 0, NULL, 'V' },
|
{ "version", 0, NULL, 'V' },
|
||||||
|
{ "debug", 0, NULL, 'D' },
|
||||||
{ "config", 1, NULL, 'c' },
|
{ "config", 1, NULL, 'c' },
|
||||||
{ "daemonize", 0, NULL, 'd' },
|
{ "daemonize", 0, NULL, 'd' },
|
||||||
#ifdef X11
|
#ifdef X11
|
||||||
@ -9360,7 +9362,9 @@ int main(int argc, char **argv)
|
|||||||
case 'd':
|
case 'd':
|
||||||
fork_to_background = 1;
|
fork_to_background = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'D':
|
||||||
|
global_debug_level++;
|
||||||
|
break;
|
||||||
#ifdef X11
|
#ifdef X11
|
||||||
case 'f':
|
case 'f':
|
||||||
set_first_font(optarg);
|
set_first_font(optarg);
|
||||||
|
11
src/conky.h
11
src/conky.h
@ -117,6 +117,17 @@ extern unsigned int text_buffer_size;
|
|||||||
#define CRIT_ERR(...) \
|
#define CRIT_ERR(...) \
|
||||||
{ ERR(__VA_ARGS__); exit(EXIT_FAILURE); }
|
{ 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 {
|
struct net_stat {
|
||||||
const char *dev;
|
const char *dev;
|
||||||
int up;
|
int up;
|
||||||
|
Loading…
Reference in New Issue
Block a user