diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channel.c | 5 | ||||
-rw-r--r-- | src/main.c | 27 | ||||
-rw-r--r-- | src/os_unix.c | 3 | ||||
-rw-r--r-- | src/os_win32.c | 3 | ||||
-rw-r--r-- | src/testdir/test_startup.vim | 19 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 54 insertions, 5 deletions
diff --git a/src/channel.c b/src/channel.c index f8a8194374..e971e17c09 100644 --- a/src/channel.c +++ b/src/channel.c @@ -178,7 +178,10 @@ ch_logfile(char_u *fname, char_u *opt) if (log_fd != NULL) { - fprintf(log_fd, "==== start log session ====\n"); + fprintf(log_fd, "==== start log session %s ====\n", + get_ctime(time(NULL), FALSE)); + // flush now, if fork/exec follows it could be written twice + fflush(log_fd); #ifdef FEAT_RELTIME profile_start(&log_start); #endif diff --git a/src/main.c b/src/main.c index 036ab0a1f7..f9b1920733 100644 --- a/src/main.c +++ b/src/main.c @@ -138,15 +138,23 @@ main atexit(vim_mem_profile_dump); #endif -#ifdef STARTUPTIME - // Need to find "--startuptime" before actually parsing arguments. +#if defined(STARTUPTIME) || defined(FEAT_JOB_CHANNEL) + // Need to find "--startuptime" and "--log" before actually parsing + // arguments. for (i = 1; i < argc - 1; ++i) - if (STRICMP(argv[i], "--startuptime") == 0) + { +# ifdef STARTUPTIME + if (STRICMP(argv[i], "--startuptime") == 0 && time_fd == NULL) { time_fd = mch_fopen(argv[i + 1], "a"); TIME_MSG("--- VIM STARTING ---"); - break; } +# endif +# ifdef FEAT_JOB_CHANNEL + if (STRICMP(argv[i], "--log") == 0) + ch_logfile((char_u *)(argv[i + 1]), (char_u *)"a"); +# endif + } #endif starttime = time(NULL); @@ -1997,6 +2005,8 @@ command_line_scan(mparm_T *parmp) // "--version" give version message // "--clean" clean context // "--literal" take files literally + // "--startuptime fname" write timing info + // "--log fname" start logging early // "--nofork" don't fork // "--not-a-term" don't warn for not a term // "--ttyfail" exit if not a term @@ -2053,6 +2063,11 @@ command_line_scan(mparm_T *parmp) want_argument = TRUE; argv_idx += 11; } + else if (STRNICMP(argv[0] + argv_idx, "log", 3) == 0) + { + want_argument = TRUE; + argv_idx += 3; + } #ifdef FEAT_CLIENTSERVER else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0) ; // already processed -- no arg @@ -2435,6 +2450,7 @@ command_line_scan(mparm_T *parmp) (char_u *)argv[0]; } // "--startuptime <file>" already handled + // "--log <file>" already handled break; // case 'd': -d {device} is handled in mch_check_win() for the @@ -3539,6 +3555,9 @@ usage(void) #ifdef STARTUPTIME main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>")); #endif +#ifdef FEAT_JOB_CHANNEL + main_msg(_("--log <file>\tStart logging to <file> early")); +#endif #ifdef FEAT_VIMINFO main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo")); #endif diff --git a/src/os_unix.c b/src/os_unix.c index 826c9c0db7..d0675e8726 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5480,6 +5480,9 @@ mch_call_shell( char_u *cmd, int options) // SHELL_*, see vim.h { +#ifdef FEAT_JOB_CHANNEL + ch_log(NULL, "executing shell command: %s", cmd); +#endif #if defined(FEAT_GUI) && defined(FEAT_TERMINAL) if (gui.in_use && vim_strchr(p_go, GO_TERMINAL) != NULL) return mch_call_shell_terminal(cmd, options); diff --git a/src/os_win32.c b/src/os_win32.c index fbf666598f..e3a57fb11d 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -4767,6 +4767,9 @@ mch_call_shell( int tmode = cur_tmode; WCHAR szShellTitle[512]; +#ifdef FEAT_JOB_CHANNEL + ch_log(NULL, "executing shell command: %s", cmd); +#endif // Change the title to reflect that we are in a subshell. if (GetConsoleTitleW(szShellTitle, ARRAY_LENGTH(szShellTitle) - 4) > 0) { diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim index 6926ba313e..c580dd0e49 100644 --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -726,6 +726,25 @@ func Test_startuptime() call delete('Xtestout') endfunc +func Test_log() + CheckFeature channel + + call assert_false(filereadable('Xlogfile')) + let after = ['qall'] + if RunVim([], after, '--log Xlogfile') + call assert_equal(1, readfile('Xlogfile') + \ ->filter({i, l -> l =~ '==== start log session'}) + \ ->len()) + " second time appends to the log + if RunVim([], after, '--log Xlogfile') + call assert_equal(2, readfile('Xlogfile') + \ ->filter({i, l -> l =~ '==== start log session'}) + \ ->len()) + endif + endif + call delete('Xlogfile') +endfunc + func Test_read_stdin() let after =<< trim [CODE] write Xtestout diff --git a/src/version.c b/src/version.c index c07ae9dbe5..0c3b01c75e 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4742, +/**/ 4741, /**/ 4740, |