aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/channel/connected_channel.c5
-rw-r--r--src/core/statistics/census_log.c (renamed from src/core/statistics/log.c)2
-rw-r--r--src/core/statistics/census_log.h (renamed from src/core/statistics/log.h)0
-rw-r--r--src/core/support/log.c10
-rw-r--r--src/core/support/log_android.c7
-rw-r--r--src/core/support/log_linux.c8
-rw-r--r--src/core/support/log_posix.c8
-rw-r--r--src/core/support/log_win32.c9
8 files changed, 20 insertions, 29 deletions
diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c
index 5dc4d7a5d4..8581fb41d6 100644
--- a/src/core/channel/connected_channel.c
+++ b/src/core/channel/connected_channel.c
@@ -289,15 +289,12 @@ static void accept_stream(void *user_data, grpc_transport *transport,
static void recv_error(channel_data *chand, call_data *calld, int line,
const char *fmt, ...) {
- char msg[512];
va_list a;
va_start(a, fmt);
- vsprintf(msg, fmt, a);
+ gpr_vlog(__FILE__, line, GPR_LOG_SEVERITY_ERROR, fmt, a);
va_end(a);
- gpr_log(__FILE__, line, GPR_LOG_SEVERITY_ERROR, "%s", msg);
-
if (chand->transport) {
grpc_transport_abort_stream(chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld),
diff --git a/src/core/statistics/log.c b/src/core/statistics/census_log.c
index 43a8653de6..9de9d2efb7 100644
--- a/src/core/statistics/log.c
+++ b/src/core/statistics/census_log.c
@@ -89,7 +89,7 @@
include the name of the structure, which will be passed as the first
argument. E.g. cl_block_initialize() will initialize a cl_block.
*/
-#include "src/core/statistics/log.h"
+#include "src/core/statistics/census_log.h"
#include <string.h>
#include "src/core/support/cpu.h"
#include <grpc/support/alloc.h>
diff --git a/src/core/statistics/log.h b/src/core/statistics/census_log.h
index e9c745cac0..e9c745cac0 100644
--- a/src/core/statistics/log.h
+++ b/src/core/statistics/census_log.h
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 <stdarg.h>
/* 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