Commits

David Wolever committed 6b561fe

Slightly simplifying id_from_env error handling, no longer logging macro executions, logging microtimes (vim72-logging revs 44e94fb9beed:ac207c6132f4)

Comments (0)

Files changed (1)

     if (filetype[0] == '\0')
         filetype = (char_u *)"unknown";
 
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+
     char msg[_CMDLOG_BUF_SIZE+64];
-    vim_snprintf(msg, sizeof(msg), "%d %s %s %s\n", time(NULL), filetype,
-                 cmdlog_get_state_str(_cmdlog_last_state), _cmdlog_buf);
+    vim_snprintf(msg, sizeof(msg), "%d.%d %s %s %s\n", tv.tv_sec, tv.tv_usec,
+                 filetype, cmdlog_get_state_str(_cmdlog_last_state),
+                 _cmdlog_buf);
     fputs(msg, cmdlogfile);
 
     done:
         cmdlog_flush_buf();
     }
 
+    if (Exec_reg == TRUE)
+        return;
+
     if (!p_cli && State == INSERT)
         return;
 
 int id_from_env(const char *name) {
     int id;
     char *idstr;
-    char *endptr;
 
     idstr = getenv(name);
     if (idstr == NULL)
         return -1;
 
-    id = strtol(idstr, &endptr, 10);
-    if (*endptr == '\0' && *endptr != *idstr)
-        return id;
+    id = strtol(idstr, NULL, 10);
+    if (errno != 0)
+        return -1;
 
-    return -1;
+    return id;
 }
 
 int ensure_cmdlog_file_is_open() {
         fchown(fileno(cmdlogfile), sudo_uid, sudo_gid);
     }
 
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+
     // Print a bit of information about vim-logging
-    fprintf(cmdlogfile, "%d none VIM-LOGGING %s\n", time(NULL),
+    fprintf(cmdlogfile, "%d.%d none VIM-LOGGING %s\n", tv.tv_sec, tv.tv_usec,
             CMDLOG_VERSION_STR);
 
     return 1;