X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Fdebug.c;h=cb3bdd558a8c9a8527578ea33defa06e8d02544f;hb=HEAD;hp=233191d95081d613f8df92624d847999eb00de0b;hpb=d5853102f67d85d8e169f9dbe973ad573306c215;p=debian%2Famanda diff --git a/common-src/debug.c b/common-src/debug.c index 233191d..cb3bdd5 100644 --- a/common-src/debug.c +++ b/common-src/debug.c @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1998 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -68,6 +69,7 @@ static void debug_unlink_old(void); static void debug_setup_1(char *config, char *subdir); static void debug_setup_2(char *s, int fd, char *annotation); static char *msg_timestamp(void); +static char *msg_thread(void); static void debug_logging_handler(const gchar *log_domain, GLogLevelFlags log_level, @@ -494,6 +496,22 @@ msg_timestamp(void) return timestamp; } +/* Get current GMT time and return a message timestamp. + * Used for g_printf calls to logs and such. The return value + * is to a static buffer, so it should be used immediately. + * + * @returns: timestamp + */ +static char * +msg_thread(void) +{ + static char thread[128]; + + sprintf(thread, "thd-%p", g_thread_self()); + + return thread; +} + /* * ---- public functions */ @@ -519,6 +537,9 @@ debug_open(char *subdir) char *s = NULL; mode_t mask; + /* create AMANDA_TMPDIR */ + make_amanda_tmpdir(); + /* set up logging while we're here */ debug_setup_logging(); @@ -775,7 +796,7 @@ printf_arglist_function(void debug_printf, const char *, format) char *text; if (db_file != stderr) - prefix = g_strdup_printf("%s: %s:", msg_timestamp(), get_pname()); + prefix = g_strdup_printf("%s: %s: %s:", msg_timestamp(), msg_thread(), get_pname()); else prefix = g_strdup_printf("%s:", get_pname()); arglist_start(argp, format);