Search code examples
vim

How to stop vim from creating log files


Every time I open vim, it generates various log files.

bt_regexp_debug.log
bt_regexp_log.log
nfa_regexp_debug.log
nfa_regexp_dump.log
nfa_regexp_run.log

Why do they get created, and how can I get read of them?


Solution

  • From regexp_nfa.c:

    #ifdef ENABLE_LOG
        log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
    
    [...]
    
    #ifdef ENABLE_LOG
        { 
            FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a");
    

    and from regexp.c:

    #ifdef BT_REGEXP_LOG
        f = fopen("bt_regexp_log.log", "a");
    

    All the calls to this seem to be wrapped in either a #ifdef ENABLE_LOG or #ifdef BT_REGEXP_LOG. On other words: they're compile-time switches.

    Looking at the top of these two files, I see:

    #ifdef DEBUG
    # define NFA_REGEXP_ERROR_LOG   "nfa_regexp_error.log"
    

    and:

    #ifdef DEBUG
    /* show/save debugging data when BT engine is used */
    # define BT_REGEXP_DUMP
    

    Conclusion: Your Vim is compiled with DEBUG defined.

    You can verify this with vim --version, where it should show DEBUG BUILD at the bottom. I don't see any way to disable creating these files at runtime; you'll need to recompile Vim.

    There doesn't seem to be a configure switch to enable/disable this. It should be disabled by default. In feature.h I see:

    /*
     * DEBUG                Output a lot of debugging garbage.
     */
    /* #define DEBUG */
    

    And in Makefile I see:

    #CFLAGS = -g -DDEBUG -Wall -Wshadow -Wmissing-prototypes
    

    Note that both are commented out.

    It's also possible you manually ran make with make CFLAGS="-DDEBUG".


    P.S. I didn't know any of this either, but quickly found the answer by using grep on the Vim source tree. Learn to love grep. grep is your friend. ;-)