Merge pull request #2307 from ctiller/im-so-pretty

Make log lines line up and be prettier
pull/2213/merge
Yang Gao 10 years ago
commit 07a44c9d51
  1. 11
      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

Loading…
Cancel
Save