App.log

Handles logging of debug/warning/error messages.

The logger supports displaying message in the console and/or toasters (using the toastr.js framework). Each log level has default settings where it should be displayed, e.g. errors are displayed both in the console and as a toaster, but debug messages are by default only displayed in the console. This can be configured using the options parameter.

Example

// Example of how to write a debug statement
App.log.debug('debug message');
// Example of how to write an error statement
App.log.error('Error when promiting object', {}, { 'more': 'info', 'can': 'be.provided' });

The active log levels determines which messages that actually are displayed.

Methods

(static) debug(message, options, argsopt)

Logs a debug statement. It is by default written to the console but not shown as a toaster.

Parameters:
Name Type Attributes Description
message String

Debug message

options Object

Options where to display message. Defaults: { useConsole: true, useToaster: false}

args Object <optional>

Additional arguments written to console. Useful for writing objects.

(static) error(message, options, argsopt)

Logs an error. It is by default written to the console and shown as a toaster.

Parameters:
Name Type Attributes Description
message String

Error message

options Object

Options where to display message. Defaults: { useConsole: true, useToaster: true}

args Object <optional>

Additional arguments written to console. Useful for writing objects.

(static) getLevel() → {App.log.levels}

Gets the current log level.

Returns:

Log level

Type
App.log.levels

(static) initialize()

Initialize the logging module.

(static) setLevel(level)

Sets the log level.

Parameters:
Name Type Description
level App.log.levels

Log level

(static) warning(message, options, argsopt)

Logs a warning statement. It is by default written to the console and shown as a toaster.

Parameters:
Name Type Attributes Description
message String

Warning message

options Object

Options where to display message. Defaults: { useConsole: true, useToaster: true}

args Object <optional>

Additional arguments written to console. Useful for writing objects.