aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-07-11 22:48:53 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-07-24 19:25:51 +0200
commit4d6a1e5566b73c938e4db35432bc975ca9389deb (patch)
treece4c2f5d62756396c5656bf75516987313b0a3cf
parentddea51954259597ce5efd03d3de34fd0fa91d1d3 (diff)
downloadrneovim-4d6a1e5566b73c938e4db35432bc975ca9389deb.tar.gz
rneovim-4d6a1e5566b73c938e4db35432bc975ca9389deb.tar.bz2
rneovim-4d6a1e5566b73c938e4db35432bc975ca9389deb.zip
log.c: message format
- Log-level name (INFO/ERROR/…) should be in the first column, so that filtering by log-level is maximally trivial. - Use 2-digit year. 4-digit year is useless, logs don't survive for decades without context. Before: 2018/07/05 17:49:41 INFO 27596 on_process_exit:393: foo After: INFO 180705.174941 27596 on_process_exit:393: foo
-rw-r--r--src/nvim/log.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/log.c b/src/nvim/log.c
index ef5b7699af..3d689db117 100644
--- a/src/nvim/log.c
+++ b/src/nvim/log.c
@@ -260,25 +260,25 @@ static bool v_do_log_to_file(FILE *log_file, int log_level,
};
assert(log_level >= DEBUG_LOG_LEVEL && log_level <= ERROR_LOG_LEVEL);
- // format current timestamp in local time
+ // Format the timestamp.
struct tm local_time;
if (os_localtime(&local_time) == NULL) {
return false;
}
char date_time[20];
- if (strftime(date_time, sizeof(date_time), "%Y/%m/%d %H:%M:%S",
+ if (strftime(date_time, sizeof(date_time), "%y%m%d.%H%M%S",
&local_time) == 0) {
return false;
}
- // print the log message prefixed by the current timestamp and pid
+ // Print the log message.
int64_t pid = os_get_pid();
int rv = (line_num == -1 || func_name == NULL)
- ? fprintf(log_file, "%s %s %" PRId64 " %s", date_time,
- log_levels[log_level], pid,
+ ? fprintf(log_file, "%s %s %" PRId64 " %s", log_levels[log_level],
+ date_time, pid,
(context == NULL ? "?:" : context))
- : fprintf(log_file, "%s %s %" PRId64 " %s%s:%d: ", date_time,
- log_levels[log_level], pid,
+ : fprintf(log_file, "%s %s %" PRId64 " %s%s:%d: ", log_levels[log_level],
+ date_time, pid,
(context == NULL ? "" : context),
func_name, line_num);
if (rv < 0) {