Yahoo! UI Library

Logger Widget  2.5.2

Yahoo! UI Library > logger > YAHOO.widget.Logger

Show Private Show Protected

static Class YAHOO.widget.Logger

The singleton Logger class provides core log management functionality. Saves logs written through the global YAHOO.log function or written by a LogWriter instance. Provides access to logs for reading by a LogReader instance or native browser console such as the Firebug extension to Firefox or Safari's JavaScript console through integration with the console.log() method.

Properties

_browserConsoleEnabled - private static Boolean

Internal property to track whether output to browser console is enabled.
Default Value: false

_lastTime - private static Date

Timestamp of last logged message.

_stack - private static Array

Array to hold all log messages.

_startTime - private static Date

Static timestamp of Logger initialization.

categories - static String[]

Array of categories.
Default Value: ["info","warn","error","time","window"]

loggerEnabled - static Boolean

True if Logger is enabled, false otherwise.
Default Value: true

maxStackEntries - static Number

Upper limit on size of internal stack.
Default Value: 2500

sources - static String[]

Array of sources.
Default Value: ["global"]

Methods

_createNewCategory

private void _createNewCategory ( sCategory )
Creates a new category of log messages and fires categoryCreateEvent.
Parameters:
sCategory <String> Category name.
Returns: void

_createNewSource

private void _createNewSource ( sSource )
Creates a new source of log messages and fires sourceCreateEvent.
Parameters:
sSource <String> Source name.
Returns: void

_isNewCategory

private Boolean _isNewCategory ( sCategory )
Checks to see if a category has already been created.
Parameters:
sCategory <String> Category name.
Returns: Boolean
Returns true if category is unknown, else returns false.

_isNewSource

private Boolean _isNewSource ( sSource )
Checks to see if a source already exists.
Parameters:
sSource <String> Source name.
Returns: Boolean
Returns true if source is unknown, else returns false.

_onWindowError

private void _onWindowError ( sMsg , sUrl , sLine )
Handles logging of messages due to window error events.
Parameters:
sMsg <String> The error message.
sUrl <String> URL of the error.
sLine <String> Line number of the error.
Returns: void

_printToBrowserConsole

private void _printToBrowserConsole ( oEntry )
Outputs a log message to global console.log() function.
Parameters:
oEntry <Object> Log entry object.
Returns: void

disableBrowserConsole

void disableBrowserConsole ( )
Disables output to the browser's global console.log() function, which is used by the Firebug extension to Firefox as well as Safari.
Returns: void

enableBrowserConsole

void enableBrowserConsole ( )
Enables output to the browser's global console.log() function, which is used by the Firebug extension to Firefox as well as Safari.
Returns: void

getStack

Object[] getStack ( )
Public accessor to internal stack of log message objects.
Returns: Object[]
Array of log message objects.

getStartTime

Date getStartTime ( )
Public accessor to internal start time.
Returns: Date
Internal date of when Logger singleton was initialized.

handleWindowErrors

void handleWindowErrors ( )
Surpresses native JavaScript errors and outputs to console. By default, Logger does not handle JavaScript window error events. NB: Not all browsers support the window.onerror event.
Returns: void

log

void log ( sMsg , sCategory , sSource )
Saves a log message to the stack and fires newLogEvent. If the log message is assigned to an unknown category, creates a new category. If the log message is from an unknown source, creates a new source. If browser console is enabled, outputs the log message to browser console.
Parameters:
sMsg <String> The log message.
sCategory <String> Category of log message, or null.
sSource <String> Source of LogWriter, or null if global.
Returns: void

reset

void reset ( )
Resets internal stack and startTime, enables Logger, and fires logResetEvent.
Returns: void

unhandleWindowErrors

void unhandleWindowErrors ( )
Unsurpresses native JavaScript errors. By default, Logger does not handle JavaScript window error events. NB: Not all browsers support the window.onerror event.
Returns: void

Events

categoryCreateEvent

categoryCreateEvent ( sCategory )
Fired when a new category has been created.
Parameters:
sCategory <String> Category name.

logResetEvent

logResetEvent ( )
Fired when the Logger has been reset has been created.

newLogEvent

newLogEvent ( sMsg )
Fired when a new log message has been created.
Parameters:
sMsg <String> Log message.

sourceCreateEvent

sourceCreateEvent ( sSource )
Fired when a new source has been named.
Parameters:
sSource <String> Source name.


Copyright © 2007 Yahoo! Inc. All rights reserved.