Module:log globals/documentation

Sends a log message if any lua global variables are set or read by any module involved in the current module invocation. A less drastic version of the  library, which triggers an error in the same situation.

This module logs uses of  global variables in code that is executed after the module is loaded. There is no deduplication so the same message can appear many times if it is triggered by more than one template.

After the name of the variable and whether it was set or accessed, a backtrace is shown. The first line of the backtrace gives the line of the module where a global variable was used, which is often the line that needs to be changed. Sometimes a global variable is used because of a misspelling; sometimes a variable is defined and  needs to be added to its definition (which requires refactoring or forward declaration if the variable is used before it is defined).

To use it, add  temporarily at the top of the module. Preview a page by entering a page in the "" box and pressing the "" button. Click to open the "" box at the bottom of the page, if it is not open already, and click the "" button next to the "" label. Inside is a log of global variables that were accessed or set in any code that was executed after this module was loaded. This includes global variables in code in other modules. After changing the global variables to local, and before saving the module, remove.