diff options
author | sleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2014-11-22 22:36:55 +0000 |
---|---|---|
committer | sleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2014-11-22 22:36:55 +0000 |
commit | f54c5197a6349977585f82676950accb39cfcd9b (patch) | |
tree | 7ee12d16dc38f7a4d58099c7003edcf6d011f940 /navit | |
parent | a2cd29a49af0f5db8cd89312f2c58a677e10e969 (diff) | |
download | navit-svn-f54c5197a6349977585f82676950accb39cfcd9b.tar.gz |
Add:core:Allow setting the debug level by name in navit.xml.|#1269, last part
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5969 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r-- | navit/attr_def.h | 1 | ||||
-rw-r--r-- | navit/debug.c | 39 | ||||
-rw-r--r-- | navit/navit_shipped.xml | 7 |
3 files changed, 39 insertions, 8 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h index b2666ae8..4ab7f70e 100644 --- a/navit/attr_def.h +++ b/navit/attr_def.h @@ -389,6 +389,7 @@ ATTR(refresh_cond) * exclude the end nodes, because these are imported as separate nodes. */ ATTR(house_number_interpolation_no_ends_incrmt_1) ATTR(house_number_interpolation_no_ends_incrmt_2) +ATTR(dbg_level) ATTR2(0x0003ffff,type_string_end) ATTR2(0x00040000,type_special_begin) ATTR(order) diff --git a/navit/debug.c b/navit/debug.c index 2aa3bcb9..8eab0d2d 100644 --- a/navit/debug.c +++ b/navit/debug.c @@ -135,14 +135,43 @@ debug_level_set(const char *name, dbg_level level) } } +static dbg_level +parse_dbg_level(struct attr *dbg_level_attr, struct attr *level_attr) +{ + if (dbg_level_attr) { + if(!strcmp(dbg_level_attr->u.str,"error")){ + return lvl_error; + } + if(!strcmp(dbg_level_attr->u.str,"warning")){ + return lvl_warning; + } + if(!strcmp(dbg_level_attr->u.str,"info")){ + return lvl_info; + } + if(!strcmp(dbg_level_attr->u.str,"debug")){ + return lvl_debug; + } + dbg(lvl_error, "Invalid debug level in config: '%s'\n", dbg_level_attr->u.str); + } else if (level_attr) { + if (level_attr->u.num>= lvl_error && + level_attr->u.num<= lvl_debug) + return level_attr->u.num; + dbg(lvl_error, "Invalid debug level in config: %ld\n", level_attr->u.num); + } + return lvl_unset; +} + struct debug * debug_new(struct attr *parent, struct attr **attrs) { - struct attr *name,*level; + struct attr *name,*dbg_level_attr,*level_attr; + dbg_level level; name=attr_search(attrs, NULL, attr_name); - level=attr_search(attrs, NULL, attr_level); + dbg_level_attr=attr_search(attrs, NULL, attr_dbg_level); + level_attr=attr_search(attrs, NULL, attr_level); + level = parse_dbg_level(dbg_level_attr,level_attr); #ifdef HAVE_SOCKET - if (!name && !level) { + if (!name && level==lvl_unset) { struct attr *socket_attr=attr_search(attrs, NULL, attr_socket); char *p,*s; if (!socket_attr) @@ -166,9 +195,9 @@ debug_new(struct attr *parent, struct attr **attrs) return (struct debug *)&dummy; } #endif - if (!name || !level) + if (!name || level==lvl_unset) return NULL; - debug_level_set(name->u.str, level->u.num); + debug_level_set(name->u.str, level); return (struct debug *)&dummy; } diff --git a/navit/navit_shipped.xml b/navit/navit_shipped.xml index 17bc57a4..c2f3f628 100644 --- a/navit/navit_shipped.xml +++ b/navit/navit_shipped.xml @@ -15,11 +15,12 @@ </plugins> <!-- The global debug level (like using command line option "-d"). Ignored if option -d is used. --> - <debug name="global" level="0"/> + <!-- Possible debug levels: error, warning, info, debug. --> + <debug name="global" dbg_level="error"/> <!-- Example of setting the debug level for a single function. --> - <debug name="navit:do_draw" level="0"/> + <debug name="navit:do_draw" dbg_level="error"/> <!-- This is here so one can copy&paste the contents of popup menus --> - <debug name="navit:popup_printf_cb" level="3"/> + <debug name="navit:popup_printf_cb" dbg_level="debug"/> <!-- segv: 1 - show backtrace with gdb and exit, 2 - stay in gdb --> <debug name="segv" level="1"/> <!-- timestamps 0/1 - prefix log messages with a timestamp --> |