Namespace RapidContext.Log

Provides a logging service for debugging apps and server calls.

All log messages are filtered by log level and either discarded or stored to an internal array. This makes it possible to either show these in a developer console or to send them to a server for remote storage.

This module also replaces the built-in console.error(), console.warn(), console.info() and console.log() functions with its own versions, passing through the filtered log messages to the original functions. For browsers without a console object, a minimal version is provided.

Source code: RapidContext_Log.js

Namespace Summary
 
Method Summary
<static>  
RapidContext.Log.clear()
Clears the log console and the array of stored messages.
<static>  
RapidContext.Log.context(value)
Returns and optionally sets the current log context.
<static>  
RapidContext.Log.debug(msg)
Logs a debug message with optional data.
<static>  
RapidContext.Log.error(msg)
Logs an error message with optional data.
<static>  
RapidContext.Log.history()
Returns the history of filtered log entries.
<static>  
RapidContext.Log.info(msg)
Logs an information message with optional data.
<static>  
RapidContext.Log.level(value)
Returns and optionally sets the current log level.
<static>  
RapidContext.Log.logBrowserInfo()
Logs a number of browser meta-data parameters (INFO level).
<static>  
RapidContext.Log.stringify(o)
Creates a string representation (suitable for logging) for any value or object.
<static>  
RapidContext.Log.warn(msg)
Logs a warning message with optional data.
Namespace Detail
RapidContext.Log
Method Detail
<static> RapidContext.Log.clear()
Clears the log console and the array of stored messages.

<static> {Array} RapidContext.Log.history()
Returns the history of filtered log entries. Each log entry is a plain object with properties -- id, time, level, context, message and data.
Returns:
{Array} the array of log entries

<static> {String} RapidContext.Log.level(value)
Returns and optionally sets the current log level. The supported log level values are -- none, error, warn, info, log and all.
Parameters:
{String} value Optional
the new log level
Returns:
{String} the current log level

<static> {String} RapidContext.Log.context(value)
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.
RapidContext.Log.context('mybutton.onclick');
...
console.warn('unsupported xyz value:', value);
...
RapidContext.Log.context(null);
Parameters:
{String} value Optional
the new log context, or null to clear
Returns:
{String} the current log context, or null for none

<static> RapidContext.Log.error(msg)
Logs an error message with optional data. Also available as the global console.error() function.
console.error('failed to initialize module');
Parameters:
{String} msg
the log message
{Object} ... Optional
the additional log data or messages

<static> RapidContext.Log.warn(msg)
Logs a warning message with optional data. Also available as the global console.warn() function.
console.warn('missing "data" attribute on document root:', document.body);
Parameters:
{String} msg
the log message
{Object} ... Optional
the additional log data or messages

<static> RapidContext.Log.info(msg)
Logs an information message with optional data. Also available as the global console.info() function.
console.info('authorization failed, user not logged in');
Parameters:
{String} msg
the log message
{Object} ... Optional
the additional log data or messages

<static> RapidContext.Log.debug(msg)
Logs a debug message with optional data. Also available as the global console.log() and console.debug() functions.
console.log('init AJAX call to URL:', url);
...
console.log('done AJAX call to URL:', url, responseCode);
Parameters:
{String} msg
the log message
{Object} ... Optional
the additional log data or messages

<static> RapidContext.Log.logBrowserInfo()
Logs a number of browser meta-data parameters (INFO level).

<static> {String} RapidContext.Log.stringify(o)
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:
{Object} o
the value or object to convert
Returns:
{String} the string representation of the value