From f7d9707866ab118b6981207be54ab78c8b022fdc Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Fri, 1 Nov 2013 13:23:25 +0100 Subject: Synced headers between PLUGIN_DEBUG, PLUGIN_ERROR and javaside * netx/net/sourceforge/jnlp/util/logging/OutputController.java: (getHeader) added thread id and name to log header. * plugin/icedteanp/IcedTeaPluginUtils.h: (PLUGIN_DEBUG) (PLUGIN_ERROR) headerrs generation code moved to macro (CREATE_HEADER0). Both headers now contains pthread_self and g_thread_self. Fixed indentation. --- plugin/icedteanp/IcedTeaPluginUtils.h | 73 ++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'plugin') diff --git a/plugin/icedteanp/IcedTeaPluginUtils.h b/plugin/icedteanp/IcedTeaPluginUtils.h index 7d2abdb..95aca25 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.h +++ b/plugin/icedteanp/IcedTeaPluginUtils.h @@ -78,43 +78,46 @@ exception statement from your version. */ } while (0) -#define PLUGIN_DEBUG(...) \ - do \ - { \ - initialize_debug(); \ - if (plugin_debug) { \ - if (plugin_debug_to_streams) { \ - if (plugin_debug_headers) { \ - char s[1000]; \ - time_t t = time(NULL); \ - struct tm * p = localtime(&t); \ - strftime(s, 1000, "%a %b %d %H:%M:%S %Z %Y", p); \ - const char *userNameforDebug = (getenv("USERNAME") == NULL) ? "unknown user" : getenv("USERNAME"); \ - fprintf (stdout, "[%s][ITW-C-PLUGIN][MESSAGE_DEBUG][%s][%s:%d] ITNPP Thread# %ld: ", \ - userNameforDebug, s, __FILE__, __LINE__, pthread_self()); \ - } \ - fprintf (stdout, __VA_ARGS__); \ - } \ - } \ +//f is after expansion used as FILE* +#define CREATE_HEADER(f) \ + do \ + { \ + char s[200]; \ + time_t t = time(NULL); \ + struct tm p; \ + localtime_r(&t, &p); \ + strftime(s, 200, "%a %b %d %H:%M:%S %Z %Y", &p); \ + const char *userNameforDebug = (getenv("USERNAME") == NULL) ? "unknown user" : getenv("USERNAME"); \ + fprintf (f, "[%s][ITW-C-PLUGIN][MESSAGE_DEBUG][%s][%s:%d] ITNPP Thread# %ld, gthread %p: ", \ + userNameforDebug, s, __FILE__, __LINE__, pthread_self(), g_thread_self ()); \ } while (0) + + +#define PLUGIN_DEBUG(...) \ + do \ + { \ + initialize_debug(); \ + if (plugin_debug) { \ + if (plugin_debug_to_streams) { \ + if (plugin_debug_headers) { \ + CREATE_HEADER(stdout); \ + } \ + fprintf (stdout, __VA_ARGS__); \ + } \ + } \ + } while (0) + -// Error reporting macro. -#define PLUGIN_ERROR(...) \ - do \ - { \ - initialize_debug(); \ - if (plugin_debug_to_streams) { \ - if (plugin_debug_headers) { \ - char s[1000]; \ - time_t t = time(NULL); \ - struct tm * p = localtime(&t); \ - strftime(s, 1000, "%A, %B %d %Y", p); \ - const char *userNameforDebug = (getenv("USERNAME") == NULL) ? "unknown user" : getenv("USERNAME"); \ - fprintf (stderr, "[%s][ITW-C-PLUGIN][ERROR_ALL][%s][%s:%d] thread %p: ", \ - userNameforDebug, s, __FILE__, __LINE__, g_thread_self ()); \ - } \ - fprintf (stderr, __VA_ARGS__); \ - } \ +#define PLUGIN_ERROR(...) \ + do \ + { \ + initialize_debug(); \ + if (plugin_debug_to_streams) { \ + if (plugin_debug_headers) { \ + CREATE_HEADER(stderr); \ + } \ + fprintf (stderr, __VA_ARGS__); \ + } \ } while (0) -- cgit v1.2.3