Module:Logger/doc

From [N8]
Jump to navigation Jump to search

This is the documentation page for Module:Logger

This is a documentation subpage for Module:Logger.
It contains usage information, categories, and other content that is not part of the original module page.
Module:Logger is required by Module:Enum.

This module is deprecated in favour of using mw.logObject(obj), but is still provided as an alternative. This module is a helper module to be used by other modules; it may not designed to be invoked directly. See GSWiki:Lua/Helper modules for a full list and more information.

ModuleFunctionTypeUseExample
Loggerlog(table)tableDeprecated: usemw.logObject(obj) instead.

Logs the contents of the table to the console (does not expand subtables).

Notes:

  • Assumes all table indices can be represented as strings - using functions or tables as indices will result in non-specific log entries
  • This is best used by adding p.logger = require('Module:Logger') to the top of the module, then calling p.logger.log(obj) in the debug console on the module page
  • This module will only print to the debug console - it has no use when used outside of the development environment and should be removed/commented out before saving
deep_log(table)tableDeprecated: usemw.logObject(obj) instead. Logs the contents of the table to the console, expanding subtables. See above notes.
dumpObject(table, options)table, table/nilModified version of mw.dumpObject. Default values of the options are:
  • clean = false;     Removes the table#n and expands all tables even if the same table appears multiple times. The output is safe to load again by lua without further processing. Does not work for circular dependencies.
  • indentSize = 2;     Number of spaces/tabs to add for each indent level.
  • useTabs = false;     Use tabs to indent instead of spaces.
  • tabSize = 4;     Used to calculate the collapseLimit.
  • collapseLimit = 0;     Maximum length for collapsing a table onto a single line.
  • collapseArrays = true;     Allow arrays to collapse onto a single line.
  • wrapLongArrays = false;     Keep arrays collapsed and simply continue on a new line if the current line is longer then collapseLimit.
  • collapseObjects = true;     Allow key-value pairs to collapse onto a single line.
  • addEqualSignSpaces = false;     Add spaces around equal signes when the table is collapsed. Non collapsed table always have spaces.
  • addBracketSpaces = true;     Add spaces between the brackets and the data for collapsed tables i.e. { 'data' }.
  • numberPrecision = -1;     Number of decimals. Trailing zeros are trimmed. Negative numbers means let lua decide.
logObject(table, options)table, table/nilUses dumpObject and prints its result to the console.
logCleanTable(table, options)table, table/nilUses dumpObject and prints its results to the console but has the following default options changed:
  • clean = true
  • indentSize = 4
  • collapseLimit = 100
  • collapseArrays = true
  • collapseObjects = true