aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/log.c')
-rw-r--r--src/nvim/log.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/log.c b/src/nvim/log.c
index d2c7782e5d..57c7c4758b 100644
--- a/src/nvim/log.c
+++ b/src/nvim/log.c
@@ -305,15 +305,15 @@ static bool v_do_log_to_file(FILE *log_file, int log_level, const char *context,
// Get a name for this Nvim instance.
// TODO(justinmk): expose this as v:name ?
- if (starting || name[0] == '\0') {
+ if (name[0] == '\0') {
// Parent servername.
const char *parent = path_tail(os_getenv(ENV_NVIM));
// Servername. Empty until starting=false.
const char *serv = path_tail(get_vim_var_str(VV_SEND_SERVER));
if (parent && parent[0] != NUL) {
snprintf(name, sizeof(name), "%s/c", parent); // "/c" indicates child.
- } else if (serv && serv[0] != NUL) {
- snprintf(name, sizeof(name), "%s", serv ? serv : "");
+ } else if (serv[0] != NUL) {
+ snprintf(name, sizeof(name), "%s", serv);
} else {
int64_t pid = os_get_pid();
snprintf(name, sizeof(name), "?.%-5" PRId64, pid);
@@ -329,6 +329,11 @@ static bool v_do_log_to_file(FILE *log_file, int log_level, const char *context,
log_levels[log_level], date_time, millis, name,
(context == NULL ? "" : context),
func_name, line_num);
+ if (name[0] == '?') {
+ // No v:servername yet. Clear `name` so that the next log can try again.
+ name[0] = '\0';
+ }
+
if (rv < 0) {
return false;
}