Module: logger

Logger for debugging and calculation output

Source:

Requires

Members

(static) debugEnabled

Status of debugging, exported to allow modules to pre-fill their own test values

Source:

(static) enabled

Status of logger, determines if console wrapper functions are executed

Source:

Methods

(static) beginFunction(functionName, argsopt) → {undefined}

Shortcut to start a group with the name of a function and its arguments

Parameters:
Name Type Attributes Description
functionName String

Name of the function, to serve as the group caption

args Array.<Any> <optional>

The function's arguments object

Source:
Example
LOG.beginFunction('myFunctionName', arguments);

(static) deep(obj)

Log an object to the console as a deep copy

Parameters:
Name Type Description
obj any
Source:

(static) enable()

Enables logging

Source:

(static) endResult(res)

Shortcut for LOG.log({result: res});LOG.groupEnd()

Parameters:
Name Type Description
res Any

result of function

Source:

(static) error(msg, title) → {undefined}

Wrapper for console.error, dependent on whether logging has been enabled

Parameters:
Name Type Description
msg String

Error message to log to console

title String

Title for error message

Source:

(static) exitFunction(resopt) → {undefined}

Use when exiting a function due to missing or invalid input(s)

Parameters:
Name Type Attributes Description
res Any <optional>

Result of the function

Source:

(static) group(msg) → {undefined}

Wrapper for console.group, dependent on whether logging has been enabled

Parameters:
Name Type Description
msg String

Message to log to console

Source:

(static) groupCollapsed(msg) → {undefined}

Wrapper for console.groupCollapsed, dependent on whether logging has been enabled

Parameters:
Name Type Description
msg String

Message to log to console

Source:

(static) groupEnd() → {undefined}

Wrapper for console.groupEnd, dependent on whether logging has been enabled

Source:

(static) log(msg, title) → {undefined}

Wrapper for console.log, dependent on whether logging has been enabled.

Parameters:
Name Type Description
msg String | Object | Array

Message to log to console

title String

Title for message

Source:

(static) logArgs(msg) → {undefined}

Wrapper for console.log when using multiple arguments or colors Used when behavior of the log() function is not desired.

Parameters:
Name Type Description
msg
Source:

(static) presetValues()

Enables debugger

Source:

(static) warn(msg, title) → {undefined}

Wrapper for console.warn, dependent on whether logging has been enabled

Parameters:
Name Type Description
msg String

Warning message to log to console

title String

Title for warning message

Source:

(inner) printArray(arr) → {String}

Takes an array of [label, value] arrays and converts to text/html with breaks after each line, padded with nonbreaking spaces so values will be aligned. Labels with an empty string as their value will not be included.

Parameters:
Name Type Description
arr Array.<Array.<String>>

Array of any length, each member must be an array of 2 strings

Source:
Example
printArray([
  ['Actual Body Weight', '70 kg'],
  ['Height', '180 cm'],
]);

// resulting HTML will appear like this (in Arial):
Actual Body Weight:  70 kg
Height:              180 cm