logs: time stamp with 1msec resolution in unix. Thanks to Ludovic Rousseau.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3858 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
4f52e7bba8
commit
5ba09f087b
|
@ -63,10 +63,10 @@ void sc_do_log_va(sc_context_t *ctx, int type, const char *file, int line, const
|
||||||
size_t left;
|
size_t left;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
char szHora[64];
|
|
||||||
#else
|
#else
|
||||||
time_t curtime;
|
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
|
struct timeval tv;
|
||||||
|
char time_string[40];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(ctx != NULL);
|
assert(ctx != NULL);
|
||||||
|
@ -92,13 +92,10 @@ void sc_do_log_va(sc_context_t *ctx, int type, const char *file, int line, const
|
||||||
st.wYear, st.wMonth, st.wDay,
|
st.wYear, st.wMonth, st.wDay,
|
||||||
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||||
#else
|
#else
|
||||||
curtime = time(NULL);
|
gettimeofday (&tv, NULL);
|
||||||
tm = localtime(&curtime);
|
tm = localtime (&tv.tv_sec);
|
||||||
|
strftime (time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", tm);
|
||||||
r = snprintf(p, left,
|
r = snprintf(p, left, "%s.%03ld ", time_string, tv.tv_usec / 1000);
|
||||||
"%i-%02i-%02i %02i:%02i:%02i ",
|
|
||||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
|
||||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
||||||
#endif
|
#endif
|
||||||
p += r;
|
p += r;
|
||||||
left -= r;
|
left -= r;
|
||||||
|
|
Loading…
Reference in New Issue