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
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.
Default Value: ["info","warn","error","time","window"]
True if Logger is enabled, false otherwise.
Default Value: true
Upper limit on size of internal stack.
Default Value: 2500
sources
- static String[]
Default Value: ["global"]
Methods
private
void
_createNewCategory
(
sCategory
)
Creates a new category of log messages and fires categoryCreateEvent.
- Parameters:
-
sCategory <String>
Category name.
- Returns:
void
private
void
_createNewSource
(
sSource
)
Creates a new source of log messages and fires sourceCreateEvent.
- Parameters:
-
sSource <String>
Source name.
- Returns:
void
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.
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.
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
private
void
_printToBrowserConsole
(
oEntry
)
Outputs a log message to global console.log() function.
- Parameters:
-
oEntry <Object>
Log entry object.
- Returns:
void
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.
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.
Object[]
getStack
(
)
Public accessor to internal stack of log message objects.
- Returns:
Object[]
- Array of log message objects.
Date
getStartTime
(
)
Public accessor to internal start time.
- Returns:
Date
- Internal date of when Logger singleton was initialized.
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.
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
void
reset
(
)
Resets internal stack and startTime, enables Logger, and fires logResetEvent.
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.
Events
categoryCreateEvent
(
sCategory
)
Fired when a new category has been created.
- Parameters:
-
sCategory <String>
Category name.
logResetEvent
(
)
Fired when the Logger has been reset has been created.
newLogEvent
(
sMsg
)
Fired when a new log message has been created.
- Parameters:
-
sMsg <String>
Log message.
sourceCreateEvent
(
sSource
)
Fired when a new source has been named.
- Parameters:
-
sSource <String>
Source name.