aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-02-04 23:35:41 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-02-04 23:35:41 +0100
commitee0c96c7fc4bdcf908969eedb96b248e33db1cbb (patch)
tree0ca350c69f4719de15a688b96ad4f320b6496b3e /src/core/support
parent21f627ad0adeb41e49112ff071c40e5609f93736 (diff)
Second draft of the win32 implementation.
-) Client code is now threadsafe. -) The echo_client code runs and succeeds.
Diffstat (limited to 'src/core/support')
-rw-r--r--src/core/support/log_win32.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core/support/log_win32.c b/src/core/support/log_win32.c
index e1cf6fb10a..4c0a866048 100644
--- a/src/core/support/log_win32.c
+++ b/src/core/support/log_win32.c
@@ -38,6 +38,7 @@
#include <grpc/support/log_win32.h>
#include <grpc/support/log.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/time.h>
#include <stdio.h>
#include <stdarg.h>
@@ -75,8 +76,20 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
/* Simple starter implementation */
void gpr_default_log(gpr_log_func_args *args) {
- fprintf(stderr, "%s.%u %s:%d: %s\n",
- gpr_log_severity_string(args->severity), GetCurrentThreadId(),
+ char time_buffer[64];
+ gpr_timespec now = gpr_now();
+ struct tm tm;
+
+ if (localtime_s(&tm, &now.tv_sec)) {
+ strcpy(time_buffer, "error:localtime");
+ } else if (0 ==
+ strftime(time_buffer, sizeof(time_buffer), "%m%d %H:%M:%S", &tm)) {
+ strcpy(time_buffer, "error:strftime");
+ }
+
+ fprintf(stderr, "%s%s.%09u %5u %s:%d: %s\n",
+ gpr_log_severity_string(args->severity), time_buffer,
+ (int)(now.tv_nsec), GetCurrentThreadId(),
args->file, args->line, args->message);
}