Hello developers,
In http://www.winehq.org/pipermail/wine-patches/2008-June/056508.html Peter Urbanec sent a patch I like, that adds timing information to the log. It has been critized for having the wrong indentation style. As I would like to give that patch a second chance, I reindented the code to match the surrounding code.
The question I have: How to give credit? The standard "based on a patch from" clause seems to weak to me, as it is aside from whitespace changes exactly that patch. But as I did these whitespace changes, it also seems wrong to just put Peter Urbanec into the From line. He did never submit in that form. I would be happy about any advice.
The indentation-fixed patch is included, although the first two lines are munged to prevent the patch to get away with the "forged" attribution.
Regards, Michael Karcher
Based-on-From 37a6d97098fa8d4de70b125f6303de5b5fa92357 Mon Sep 17 00:00:00 2001 Based-on-From: Peter Urbanec winehq.org@urbanec.net Date: Wed, 25 Jun 2008 02:45:46 +1000 Subject: [PATCH] ntdll: Add timestamp channel to log output.
This patch will prefix every line of log output with a time stamp if the "timestamps" debug channel is enabled.
The time stamps are formatted as [seconds.microseconds] and measured as elapsed time from the epoch. This helps with tracking down time sensitive bugs and it may also come in handy when investigating performance. --- dlls/ntdll/debugtools.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c index cb08285..324cff4 100644 --- a/dlls/ntdll/debugtools.c +++ b/dlls/ntdll/debugtools.c @@ -29,6 +29,7 @@ # include <unistd.h> #endif #include <ctype.h> +#include <sys/time.h>
#include "wine/debug.h" #include "wine/exception.h" @@ -39,6 +40,7 @@ #include "ntdll_misc.h"
WINE_DECLARE_DEBUG_CHANNEL(tid); +WINE_DECLARE_DEBUG_CHANNEL(timestamps);
static struct __wine_debug_functions default_funcs;
@@ -164,8 +166,16 @@ static int NTDLL_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_chan /* only print header if we are at the beginning of the line */ if (info->out_pos == info->output || info->out_pos[-1] == '\n') { + /* Prepend a timestamp to each line, if requested. */ + if (TRACE_ON(timestamps)) + { + struct timeval tv; + if (!gettimeofday(&tv, NULL)) + ret += wine_dbg_printf( "[%ld.%06ld] ", tv.tv_sec, tv.tv_usec); + } + if (TRACE_ON(tid)) - ret = wine_dbg_printf( "%04x:", GetCurrentThreadId() ); + ret += wine_dbg_printf( "%04x:", GetCurrentThreadId() ); if (cls < sizeof(classes)/sizeof(classes[0])) ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel->name, function ); }