static GHashTable *debug_hash;
static char *gdb_program;
+static FILE *debug_fp;
+
static void sigsegv(int sig)
{
#if defined(_WIN32) || defined(__CEGCC__)
gdb_program=program_name;
signal(SIGSEGV, sigsegv);
debug_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ debug_fp = stderr;
}
sprintf(buffer, "%s:%s", module, function);
if (debug_level_get(module) >= level || debug_level_get(buffer) >= level) {
if (prefix)
- fprintf(stderr,"%s:",buffer);
- vfprintf(stderr,fmt, ap);
+ fprintf(debug_fp,"%s:",buffer);
+ vfprintf(debug_fp,fmt, ap);
+ fflush(debug_fp);
}
}
debug_printf(0,module,mlen,function,flen,1,"%s:%d assertion failed:%s\n", file, line, expr);
abort();
}
+
+void
+debug_destroy(void)
+{
+ if (!debug_fp)
+ return;
+ if (debug_fp == stderr || debug_fp == stdout)
+ return;
+ fclose(debug_fp);
+ debug_fp = NULL;
+}
+
+void debug_set_logfile(const char *path)
+{
+ FILE *fp;
+ fp = fopen(path, "a");
+ if (fp) {
+ debug_destroy();
+ debug_fp = fp;
+ fprintf(debug_fp, "Navit log started\n");
+ fflush(debug_fp);
+ }
+}
/* prototypes */
struct attr;
void debug_init(const char *program_name);
+void debug_destroy(void);
+void debug_set_logfile(const char *path);
void debug_level_set(const char *name, int level);
int debug_level_get(const char *name);
struct debug *debug_new(struct attr *parent, struct attr **attrs);