diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-04-12 15:09:23 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-12 15:09:23 +0100 |
commit | c9a9a0ac1ec3b985d38c01ddf9f0ba2f15386f34 (patch) | |
tree | fb5fdcc958f7d680b56c8a096f033afd5874fef7 /src/main.c | |
parent | 60895f3e36def9beb7d5463e792e5154ad9a7a0a (diff) |
patch 8.2.4742: there is no way to start logging very early in startupv8.2.4742
Problem: There is no way to start logging very early in startup.
Solution: Add the --log argument. Include the date in the start message in
the log file. Avoid a duplicate message when forking. Log an
executed shell command.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 27 |
1 files changed, 23 insertions, 4 deletions
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 |