[Spice-devel] [vdagent-win PATCH v4 19/19] vdlog: Use GetLocalTime instead of multiple C functions
Frediano Ziglio
fziglio at redhat.com
Mon Jul 2 07:43:58 UTC 2018
The GetLocalTime function already returns all information we
need for the log, no needs to call multiple C functions.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
common/vdlog.cpp | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/common/vdlog.cpp b/common/vdlog.cpp
index 8c11d33..e2561e2 100644
--- a/common/vdlog.cpp
+++ b/common/vdlog.cpp
@@ -84,18 +84,15 @@ void VDLog::logf(const char *type, const char *function, const char* format, ...
FILE *fh = _log ? _log->_handle : stdout;
va_list args;
- struct _timeb now;
- struct tm today;
- char datetime_str[20];
- _ftime_s(&now);
- localtime_s(&today, &now.time);
- strftime(datetime_str, 20, "%Y-%m-%d %H:%M:%S", &today);
+ SYSTEMTIME st;
+ GetLocalTime(&st);
_lock_file(fh);
- fprintf(fh, "%lu::%s::%s,%.3d::%s::",
+ fprintf(fh, "%lu::%s::%.4u-%.2u-%.2u %.2u:%.2u:%.2u,%.3u::%s::",
GetCurrentThreadId(), type,
- datetime_str,
- now.millitm,
+ st.wYear, st.wMonth, st.wDay,
+ st.wHour, st.wMinute, st.wSecond,
+ st.wMilliseconds,
function);
va_start(args, format);
--
2.17.1
More information about the Spice-devel
mailing list