Log Class
Log provides a centralized system for outputting errors. By default it will attempt to use console.log to output messages, but this can be changed by setting the out property.
Constructor
Log
()
Item Index
Methods
addKeys
-
keys
Adds a definition object that associates one or more keys with longer messages.
These messages can optionally include "%DETAILS%" which will be replaced by any details passed
with the error. For example:
Log.addKeys( {MYERROR:"This is a description of my error [%DETAILS%]"} );
Log.error( "MYERROR" , 5 ); // outputs "This is a description of my error [5]"
Parameters:
-
keys
ObjectThe generic object defining the keys and messages.
error
-
message
-
details
-
level
Outputs the specified error via the method assigned to the "out" property. If the error matches a key in any of the loaded def objects, it will substitute that message.
Properties
out
Function
static
Defines the function that will be used to handle any logged messages. By default it will use console.log. The
specified function will be passed the same three parameters as Log.log, but the message will
be expanded if a matching key was found.
For example, you could use this to log any messages to a server, or output it to a TextArea. You can disable all
logging by setting this to null.
All messages are passed to the out function regardless of level settings, and the function must handle the level
appropriately. This is to allow, for example, functions that log all messages to a server, but only display
messages under the current level in the UI.
out
Function
static
Specifies the level of messages to output. For example, if you set Log.level = Log.WARNING
, then any
messages with a level of 2 (Log.WARNING) or less (ex. Log.ERROR) will be output. Defaults to Log.ALL.
Default: 255