Expand all

mw.log

Log debug messages and developer warnings to the browser console.

See mw.log() for verbose debug logging.

Methods

deprecate(obj, key, val, [msg], [logName])static #

Create a property on a host object that, when accessed, will log a deprecation warning to the console.

Examples

mw.log.deprecate( window, 'myGlobalFn', myGlobalFn );
mw.log.deprecate( Thing, 'old', old, 'Use Other.thing instead', 'Thing.old'  );

Parameters:

Name Type Attributes Description
obj Object

Host object of deprecated property

key string

Name of property to create in obj

val any

The value this property should return when accessed

msg string optional

Optional extra text to add to the deprecation warning

logName string optional

Name of the feature for deprecation tracker. Tracking is disabled by default, except for global variables on window.

Source:

Create a property on a host object that, when accessed, will log a deprecation warning to the console.

error(…msg)static #

Write a message to the browser console's error channel.

Most browsers also print a stacktrace when calling this method if the argument is an Error object.

Parameters:

Name Type Attributes Description
msg Mixed repeatable

Messages to output to console

Since:
  • 1.26
Source:
Write a message to the browser console's error channel.

makeDeprecated(key, msg) → {function}static #

Create a function that logs a deprecation warning when called.

Example

var deprecatedNoB = mw.log.makeDeprecated( 'hello_without_b', 'Use of hello without b is deprecated.' );

function hello( a, b ) {
  if ( b === undefined ) {
    deprecatedNoB();
    b = 0;
  }
  return a + b;
}

hello( 1 );

Parameters:

Name Type Description
key string | null

Name of the feature for deprecation tracker, or null for a console-only deprecation.

msg string

Deprecation warning.

Since:
  • 1.38
Source:

Returns:

Type
function
Create a function that logs a deprecation warning when called.

warn(…msg)static #

Write a message to the browser console's warning channel.

Parameters:

Name Type Attributes Description
msg string repeatable

Messages to output to console

Source:
Write a message to the browser console's warning channel.