X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=logging%2Flog.c;h=0d317f031c27774fc96ac4514e7dc7342d961f6a;hb=8486e87ac1fcf63e2a9df72ed8cec28428443885;hp=1a9fed4bc486c8fcec0673daf1569d020dcbd5ad;hpb=ee07b1e97986cfaf1ee0753230191c44fea9f470;p=babeltrace.git diff --git a/logging/log.c b/logging/log.c index 1a9fed4b..0d317f03 100644 --- a/logging/log.c +++ b/logging/log.c @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef __CYGWIN__ extern unsigned long pthread_getsequence_np(pthread_t *); @@ -128,11 +129,10 @@ extern unsigned long pthread_getsequence_np(pthread_t *); #else #define BT_LOG_OPTIMIZE_SIZE 0 #endif -/* Size of the log line buffer. The buffer is allocated on stack. It limits - * maximum length of a log line. +/* Size of the log line buffer. The buffer is a globally allocated per thread. */ #ifndef BT_LOG_BUF_SZ - #define BT_LOG_BUF_SZ 512 + #define BT_LOG_BUF_SZ (4 * 4096) #endif /* Default number of bytes in one line of memory output. For large values * BT_LOG_BUF_SZ also must be increased. @@ -289,7 +289,7 @@ extern unsigned long pthread_getsequence_np(pthread_t *); #undef __STRICT_ANSI__ #endif #endif -#include +#include #include #include #include @@ -490,7 +490,8 @@ extern unsigned long pthread_getsequence_np(pthread_t *); #define memccpy _memccpy #endif -#if (defined(_MSC_VER) && !defined(__INTEL_COMPILER)) || defined(__MINGW64__) +#if (defined(_MSC_VER) && !defined(__INTEL_COMPILER)) || \ + (defined(__MINGW64__) && !defined(__USE_MINGW_ANSI_STDIO)) #define vsnprintf(s, sz, fmt, va) fake_vsnprintf(s, sz, fmt, va) static int fake_vsnprintf(char *s, size_t sz, const char *fmt, va_list ap) { @@ -536,11 +537,10 @@ static void buffer_callback(bt_log_message *msg, char *buf); STATIC_ASSERT(eol_fits_eol_sz, sizeof(BT_LOG_EOL) <= BT_LOG_EOL_SZ); STATIC_ASSERT(eol_sz_greater_than_zero, 0 < BT_LOG_EOL_SZ); STATIC_ASSERT(eol_sz_less_than_buf_sz, BT_LOG_EOL_SZ < BT_LOG_BUF_SZ); -#if !defined(_WIN32) && !defined(_WIN64) - STATIC_ASSERT(buf_sz_less_than_pipe_buf, BT_LOG_BUF_SZ <= PIPE_BUF); -#endif static const char c_hex[] = "0123456789abcdef"; +static char __thread logging_buf[4 * 4096]; + static INSTRUMENTED_CONST unsigned g_buf_sz = BT_LOG_BUF_SZ - BT_LOG_EOL_SZ; static INSTRUMENTED_CONST time_cb g_time_cb = time_callback; static INSTRUMENTED_CONST pid_cb g_pid_cb = pid_callback; @@ -684,6 +684,7 @@ static const bt_log_output out_stderr = {BT_LOG_OUT_STDERR}; BT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL = 0; #endif +BT_HIDDEN const bt_log_spec _bt_log_stderr_spec = { BT_LOG_GLOBAL_FORMAT, @@ -1261,7 +1262,7 @@ static void _bt_log_write_imp( const int lvl, const char *const tag, const char *const fmt, va_list va) { bt_log_message msg; - char buf[BT_LOG_BUF_SZ]; + char *buf = logging_buf; const unsigned mask = log->output->mask; msg.lvl = lvl; msg.tag = tag;