|
|
@ -43,6 +43,7 @@ |
|
|
|
#include <grpc/support/log.h> |
|
|
|
#include <grpc/support/log.h> |
|
|
|
#include <grpc/support/time.h> |
|
|
|
#include <grpc/support/time.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "src/core/support/string.h" |
|
|
|
#include "src/core/support/string_win32.h" |
|
|
|
#include "src/core/support/string_win32.h" |
|
|
|
|
|
|
|
|
|
|
|
void gpr_log(const char *file, int line, gpr_log_severity severity, |
|
|
|
void gpr_log(const char *file, int line, gpr_log_severity severity, |
|
|
@ -55,7 +56,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, |
|
|
|
va_start(args, format); |
|
|
|
va_start(args, format); |
|
|
|
ret = _vscprintf(format, args); |
|
|
|
ret = _vscprintf(format, args); |
|
|
|
va_end(args); |
|
|
|
va_end(args); |
|
|
|
if (!(0 <= ret && ret < ~(size_t)0)) { |
|
|
|
if (ret < 0) { |
|
|
|
message = NULL; |
|
|
|
message = NULL; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/* Allocate a new buffer, with space for the NUL terminator. */ |
|
|
|
/* Allocate a new buffer, with space for the NUL terminator. */ |
|
|
@ -66,7 +67,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, |
|
|
|
va_start(args, format); |
|
|
|
va_start(args, format); |
|
|
|
ret = vsnprintf_s(message, strp_buflen, _TRUNCATE, format, args); |
|
|
|
ret = vsnprintf_s(message, strp_buflen, _TRUNCATE, format, args); |
|
|
|
va_end(args); |
|
|
|
va_end(args); |
|
|
|
if (ret != strp_buflen - 1) { |
|
|
|
if ((size_t)ret != strp_buflen - 1) { |
|
|
|
/* This should never happen. */ |
|
|
|
/* This should never happen. */ |
|
|
|
gpr_free(message); |
|
|
|
gpr_free(message); |
|
|
|
message = NULL; |
|
|
|
message = NULL; |
|
|
@ -90,7 +91,7 @@ void gpr_default_log(gpr_log_func_args *args) { |
|
|
|
strcpy(time_buffer, "error:strftime"); |
|
|
|
strcpy(time_buffer, "error:strftime"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "%s%s.%09u %5u %s:%d] %s\n", |
|
|
|
fprintf(stderr, "%s%s.%09u %5lu %s:%d] %s\n", |
|
|
|
gpr_log_severity_string(args->severity), time_buffer, |
|
|
|
gpr_log_severity_string(args->severity), time_buffer, |
|
|
|
(int)(now.tv_nsec), GetCurrentThreadId(), |
|
|
|
(int)(now.tv_nsec), GetCurrentThreadId(), |
|
|
|
args->file, args->line, args->message); |
|
|
|
args->file, args->line, args->message); |
|
|
@ -105,6 +106,7 @@ char *gpr_format_message(DWORD messageid) { |
|
|
|
NULL, messageid, |
|
|
|
NULL, messageid, |
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
|
|
(LPTSTR)(&tmessage), 0, NULL); |
|
|
|
(LPTSTR)(&tmessage), 0, NULL); |
|
|
|
|
|
|
|
if (status == 0) return gpr_strdup("Unable to retreive error string"); |
|
|
|
message = gpr_tchar_to_char(tmessage); |
|
|
|
message = gpr_tchar_to_char(tmessage); |
|
|
|
LocalFree(tmessage); |
|
|
|
LocalFree(tmessage); |
|
|
|
return message; |
|
|
|
return message; |
|
|
|