Methods
(static) clear()
Clears the log console and the array of stored messages.
- Parameters:
-
Type Description - See:
- RapidContext.Log.history
- Source:
- RapidContext_Log.js, line 97
(static) context(valueopt) → {string}
Returns and optionally sets the current log context. The log context is used to tag all subsequent log messages until the context is removed or modified.
- Parameters:
-
Name Type Attributes Description value{string} <optional>
the new log context, or null to clear - Returns:
- {string} the current log context, or null for none
- Example:
-
RapidContext.Log.context('mybutton.onclick'); ... console.warn('unsupported xyz value:', value); ... RapidContext.Log.context(null); - Source:
- RapidContext_Log.js, line 175
(static) debug(msg, …dataopt)
Logs a debug message with optional data. Also available as the global
console.log() and console.debug() functions.
- Parameters:
-
Name Type Attributes Description msg{string} the log message data{Object} <optional>
<repeatable>
the additional log data or messages - Example:
-
console.log('init AJAX call to URL:', url); ... console.log('done AJAX call to URL:', url, responseCode); - Source:
- RapidContext_Log.js, line 260
(static) error(msg, …dataopt)
Logs an error message with optional data. Also available as the global
console.error() function.
- Parameters:
-
Name Type Attributes Description msg{string} the log message data{Object} <optional>
<repeatable>
the additional log data or messages - Example:
-
console.error('failed to initialize module'); - Source:
- RapidContext_Log.js, line 198
(static) history() → {Array}
Returns the history of filtered log entries. Each log entry is a plain
object with properties -- id, time, level, context, message
and data.
- Parameters:
-
Type Description - Returns:
- {Array} the array of log entries
- Source:
- RapidContext_Log.js, line 113
(static) info(msg, …dataopt)
Logs an information message with optional data. Also available as the
global console.info() function.
- Parameters:
-
Name Type Attributes Description msg{string} the log message data{Object} <optional>
<repeatable>
the additional log data or messages - Example:
-
console.info('authorization failed, user not logged in'); - Source:
- RapidContext_Log.js, line 238
(static) init(optsopt)
Initializes and configures the logging module. Will modify the console
object for logging. This replaces the default console.error,
console.warn, console.info, console.log and console.debug
functions. Safe to call multiple times to change or update config.
- Parameters:
-
Name Type Attributes Description opts{Object} <optional>
the log configuration options, or null Properties
Name Type Attributes Description interval{number} <optional>
the publish delay in millis, default is 10s url{string} <optional>
the publish URL endpoint filter{function} <optional>
the event filter, returns a boolean publisher{function} <optional>
the event publisher, returns a Promise - Source:
- RapidContext_Log.js, line 67
(static) level(valueopt) → {string}
Returns and optionally sets the current log level. The supported log level values are -- "none", "error", "warn", "info", "log" and "all".
- Parameters:
-
Name Type Attributes Description value{string} <optional>
the new log level - Returns:
- {string} the current log level
- Source:
- RapidContext_Log.js, line 126
(static) stringify(val) → {string}
Creates a string representation (suitable for logging) for any value or object. The returned string is similar to a JSON representation of the value, but may be simplified for increased readability.
- Parameters:
-
Name Type Description val{Object} the value or object to convert - Returns:
- {string} the string representation of the value
- Source:
- RapidContext_Log.js, line 398
(static) warn(msg, …dataopt)
Logs a warning message with optional data. Also available as the global
console.warn() function.
- Parameters:
-
Name Type Attributes Description msg{string} the log message data{Object} <optional>
<repeatable>
the additional log data or messages - Example:
-
console.warn('missing "data" attribute on document root:', document.body); - Source:
- RapidContext_Log.js, line 218