[Spice-devel] [PATCH vdagent-win 3/3] vdlog: change log times to human readable date & time rhbz#672828
Alon Levy
alevy at redhat.com
Wed Nov 16 03:54:27 PST 2011
On Wed, Nov 16, 2011 at 12:16:37PM +0200, Arnon Gilboa wrote:
> ifndef USE_DATE_TIME, use system time instead of secs from system startup
Why do we want to keep the old behavior?
> ---
> common/vdlog.h | 23 ++++++++++++++++++++---
> 1 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/common/vdlog.h b/common/vdlog.h
> index bb2eb28..995e9d3 100644
> --- a/common/vdlog.h
> +++ b/common/vdlog.h
> @@ -22,8 +22,10 @@
> #include <tchar.h>
> #include <crtdbg.h>
> #include <windows.h>
> +#include <time.h>
>
> #define LOG_ENABLED
> +#define USE_DATE_TIME
>
> class VDLog {
> public:
> @@ -40,15 +42,30 @@ private:
> };
>
> #ifdef LOG_ENABLED
> +
> +#ifndef USE_DATE_TIME
> +#define vd_printf(format, ...) { \
> + VDLog* log = VDLog::get(); \
> + if (log) { \
> + log->printf("%ld %s: " format "\n", _time64(NULL), __FUNCTION__, __VA_ARGS__); \
> + } else { \
> + printf("%ld %s: " format "\n", _time64(NULL), __FUNCTION__, __VA_ARGS__); \
> + } \
> +}
> +#else
> #define vd_printf(format, ...) { \
> VDLog* log = VDLog::get(); \
> - double secs = GetTickCount() / 1000.0; \
> + char date_str[9]; \
> + char time_str[9]; \
> + _strdate_s(date_str, sizeof(date_str)); \
> + _strtime_s(time_str, sizeof(time_str)); \
> if (log) { \
> - log->printf("%.3f %s: " format "\n", secs, __FUNCTION__, __VA_ARGS__); \
> + log->printf("%s %s %s: " format "\n", date_str, time_str, __FUNCTION__, __VA_ARGS__); \
> } else { \
> - printf("%.3f %s: " format "\n", secs, __FUNCTION__, __VA_ARGS__); \
> + printf("%s %s %s: " format "\n", date_str, time_str, __FUNCTION__, __VA_ARGS__); \
> } \
> }
> +#endif //USE_DATE_TIME
>
> #define ASSERT(x) _ASSERTE(x)
> #else
> --
> 1.7.4.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list