diff options
author | Craig Tiller <ctiller@google.com> | 2015-07-06 09:50:55 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-07-06 10:27:00 -0700 |
commit | f81ac3aced7fecde79458d9ec1b08414ddcdba06 (patch) | |
tree | 5f04f2f1fc677393e6abe1ab918e31b151cc7cdd | |
parent | 775eaec77026ebb879c66f742bf03f99e50b2378 (diff) |
Make log lines line up and be prettier
-rw-r--r-- | src/core/support/log_linux.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/support/log_linux.c b/src/core/support/log_linux.c index 48349d2c83..7937466b79 100644 --- a/src/core/support/log_linux.c +++ b/src/core/support/log_linux.c @@ -43,7 +43,9 @@ #ifdef GPR_LINUX +#include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/time.h> #include <stdio.h> #include <stdarg.h> @@ -71,6 +73,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, void gpr_default_log(gpr_log_func_args *args) { char *final_slash; + char *prefix; const char *display_file; char time_buffer[64]; gpr_timespec now = gpr_now(); @@ -89,10 +92,12 @@ void gpr_default_log(gpr_log_func_args *args) { strcpy(time_buffer, "error:strftime"); } - fprintf(stderr, "%s%s.%09d %7ld %s:%d] %s\n", + gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]", gpr_log_severity_string(args->severity), time_buffer, - (int)(now.tv_nsec), gettid(), display_file, args->line, - args->message); + (int)(now.tv_nsec), gettid(), display_file, args->line); + + fprintf(stderr, "%-60s %s\n", prefix, args->message); + gpr_free(prefix); } #endif |