From 8a67b5c281d65c308fdfc8c898c7c19673dca9cb Mon Sep 17 00:00:00 2001 From: nnoble Date: Fri, 12 Dec 2014 10:48:34 -0800 Subject: Tweaking log calls a bit. -) Introducing gpr_vlog so to spare a few vsprintf later (at least one for now) -) Renaming statistics/log.* to statistics/census_log.* to avoid collisions. Change on 2014/12/12 by nnoble ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81995756 --- src/core/support/log.c | 10 ++++++++++ src/core/support/log_android.c | 7 ++----- src/core/support/log_linux.c | 8 ++------ src/core/support/log_posix.c | 8 ++------ src/core/support/log_win32.c | 9 ++------- 5 files changed, 18 insertions(+), 24 deletions(-) (limited to 'src/core/support') diff --git a/src/core/support/log.c b/src/core/support/log.c index 79321f7ffe..b9e2897efc 100644 --- a/src/core/support/log.c +++ b/src/core/support/log.c @@ -46,3 +46,13 @@ const char *gpr_log_severity_string(gpr_log_severity severity) { } return "UNKNOWN"; } + +void gpr_log(const char *file, int line, gpr_log_severity severity, + const char *format, ...) { + va_list args; + va_start(args, format); + + gpr_vlog(file, line, severity, format, args); + + va_end(args); +} diff --git a/src/core/support/log_android.c b/src/core/support/log_android.c index 9e2b03471f..4c83e09914 100644 --- a/src/core/support/log_android.c +++ b/src/core/support/log_android.c @@ -54,15 +54,13 @@ static android_LogPriority severity_to_log_priority(gpr_log_severity severity) { return ANDROID_LOG_DEFAULT; } -void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...) { +void gpr_vlog(const char *file, int line, gpr_log_severity severity, + const char *format, va_list args) { char *final_slash; const char *display_file; char *prefix = NULL; char *suffix = NULL; char *output = NULL; - va_list args; - va_start(args, format); final_slash = strrchr(file, '/'); if (final_slash == NULL) @@ -73,7 +71,6 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, asprintf(&prefix, "%s:%d] ", display_file, line); vasprintf(&suffix, format, args); asprintf(&output, "%s%s", prefix, suffix); - va_end(args); __android_log_write(severity_to_log_priority(severity), "GRPC", output); diff --git a/src/core/support/log_linux.c b/src/core/support/log_linux.c index e39e2cc166..322ff07dd9 100644 --- a/src/core/support/log_linux.c +++ b/src/core/support/log_linux.c @@ -49,15 +49,13 @@ static long gettid() { return syscall(__NR_gettid); } -void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...) { +void gpr_vlog(const char *file, int line, gpr_log_severity severity, + const char *format, va_list args) { char *final_slash; const char *display_file; char time_buffer[64]; gpr_timespec now = gpr_now(); struct tm tm; - va_list args; - va_start(args, format); final_slash = strrchr(file, '/'); if (final_slash == NULL) @@ -78,8 +76,6 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, vfprintf(stderr, format, args); fputc('\n', stderr); funlockfile(stderr); - - va_end(args); } #endif diff --git a/src/core/support/log_posix.c b/src/core/support/log_posix.c index 68882f7e89..b47c433cd7 100644 --- a/src/core/support/log_posix.c +++ b/src/core/support/log_posix.c @@ -47,15 +47,13 @@ static long gettid() { return pthread_self(); } -void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...) { +void gpr_vlog(const char *file, int line, gpr_log_severity severity, + const char *format, va_list args) { char *final_slash; const char *display_file; char time_buffer[64]; gpr_timespec now = gpr_now(); struct tm tm; - va_list args; - va_start(args, format); final_slash = strrchr(file, '/'); if (final_slash == NULL) @@ -76,8 +74,6 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, vfprintf(stderr, format, args); fputc('\n', stderr); funlockfile(stderr); - - va_end(args); } #endif /* defined(GPR_POSIX_LOG) */ diff --git a/src/core/support/log_win32.c b/src/core/support/log_win32.c index fb2fc0c239..e6567dca7e 100644 --- a/src/core/support/log_win32.c +++ b/src/core/support/log_win32.c @@ -40,16 +40,11 @@ #include /* Simple starter implementation */ -void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...) { - va_list args; - va_start(args, format); - +void gpr_vlog(const char *file, int line, gpr_log_severity severity, + const char *format, va_list args) { fprintf(stderr, "%s %s:%d: ", gpr_log_severity_string(severity), file, line); vfprintf(stderr, format, args); fputc('\n', stderr); - - va_end(args); } #endif -- cgit v1.2.3