Console creates a visualization for messages logged through calls to a YUI
instance's Y.log( message, category, source ) method. The
debug versions of YUI modules will include logging statements to offer some
insight into the steps executed during that module's operation. Including
log statements in your code will cause those messages to also appear in the
Console. Use Console to aid in developing your page or application.
Entry categories "info", "warn", and "error" are also referred to as the log level, and entries are filtered against the configured logLevel.
_afterCollapsedChangee
Updates the className of the contentBox, which should trigger CSS to hide or show the body and footer sections depending on the new value.
e
Event
Custom event for the attribute change
_afterConsoleLimitChangee
Calls this._trimOldEntries() in response to changes in the configured consoleLimit attribute.
e
Event
Custom event for the attribute change
_afterPausedChangee
Updates the UI and schedules or cancels the print loop.
e
Event
Custom event for the attribute change
_afterStringsChangee
Updates the UI if changes are made to any of the strings in the strings attribute.
e
Event
Custom event for the attribute change
_afterVisibleChangee
Makes adjustments to the UI if needed when the Console is hidden or shown
e
Event
the visibleChange event
_cancelPrintLoopClears the timeout for printing buffered messages.
_createEntryHTMLm
Translates message meta into the markup for a console entry.
m
Object
object literal containing normalized message metadata
_defEntryFne
Buffers incoming message objects and schedules the printing.
e
Event
The Custom event carrying the message in its payload
_defResetFnClears the console, resets the startTime attribute, enables and unpauses the widget.
_encodeHTMLs
Returns the input string with ampersands (&), <, and > encoded as HTML entities.
s
String
the raw string
_getUseBrowserConsoleGetter method for useBrowserConsole attribute. Just a pass through to the YUI instance configuration setting.
_htmlEscapeMessagem
Performs HTML escaping on strings in the message object.
m
Object
the normalized message object
_initBodyCreate the DOM structure for the console body—where messages are rendered.
_initFootCreate the DOM structure for the footer elements.
_initHeadCreate the DOM structure for the header elements.
_isInLogLevelDetermine if incoming log messages are within the configured logLevel to be buffered for printing.
_normalizeMessagee
Create a log entry message from the inputs including the following keys:
e
Event
custom event containing the log message
_onClearClicke
Event handler for clicking on the Clear button. Pass-through to
this.clearConsole().
e
Event
DOM event facade for the click event
_onCollapseClicke
Event handler for clicking on the Collapse/Expand button. Sets the "collapsed" attribute accordingly.
e
Event
DOM event facade for the click event
_onLogEventmsg
cat
src
Responds to log events by normalizing qualifying messages and passing them along through the entry event for buffering etc.
_onPauseClicke
Event handler for clicking on the Pause checkbox to update the paused attribute.
e
Event
DOM event facade for the click event
_schedulePrintSets an interval for buffered messages to be output to the console.
_setLogLevelv
Setter method for logLevel attribute. Acceptable values are "error", "warn", and "info" (case insensitive). Other values are treated as "info".
v
String
the desired log level
_setUseBrowserConsolev
Setter method for useBrowserConsole attributes. Only functional if the logSource attribute points to a YUI instance. Passes the value down to the YUI instance. NOTE: multiple Console instances cannot maintain independent useBrowserConsole values, since it is just a pass through to the YUI instance configuration.
v
Boolean
false to disable browser console printing (default)
_trimOldEntriesRemoves the oldest message entries from the UI to maintain the limit specified in the consoleLimit configuration.
_uiSetHeightv
Set the height of the Console container. Set the body height to the difference between the configured height and the calculated heights of the header and footer. Overrides Widget.prototype._uiSetHeight.
_uiSizeCBOver-ride default content box sizing to do nothing, since we're sizing the body section to fill out height ourselves.
_uiUpdateCollapsedv
Updates the UI to reflect the new Collapsed state
v
Boolean
true for collapsed, false for expanded
_uiUpdateFromHideShowv
Recalculates dimensions and updates appropriately when shown
v
Boolean
true for visible, false for hidden
_uiUpdatePausedon
Checks or unchecks the paused checkbox
on
Boolean
the new checked state
_validateLogSourcev
Validator for logSource attribute.
v
Object
the desired logSource
on
method
_validateStylestyle
Validates input value for style attribute. Accepts only values 'inline', 'block', and 'separate'.
style
String
the proposed value
bindUISet up event listeners to wire up the UI to the internal state.
clearConsoleClear the console of messages and flush the buffer of pending messages.
collapseCollapses the body and footer.
destructorTears down the instance, flushing event subscriptions and purging the UI.
expandExpands the body and footer if collapsed.
initializerConstructor code. Set up the buffer and entry template, publish internal events, and subscribe to the configured logEvent.
logarg
Wrapper for Y.log.
arg
MIXED
multiple
(all arguments passed through to Y.log)
printBufferlimit
Outputs buffered messages to the console UI. This is typically called from a scheduled interval until the buffer is empty (referred to as the print loop). The number of buffered messages output to the Console is limited to the number provided as an argument. If no limit is passed, all buffered messages are rendered.
limit
Number
(optional) max number of buffered entries to write
renderUIGenerate the Console UI.
resetClears the console and resets internal timers.
scrollToLatestScrolls to the most recent entry
syncUISync the UI state to the current attribute state.
_bodyReference to the Node instance that will house the console messages.
Default: null
_evtCatCategory to prefix all event subscriptions to allow for ease of detach during destroy.
_printLoopHolds the object API returned from Y.later for the print
loop interval.
Default: null
ATTRSStatic property used to define the default attribute configuration of the Widget.
BODY_TEMPLATEMarkup template used to generate the DOM structure for the Console body (where the messages are inserted) when it is rendered. The template includes only the {placeholder} "consolebdclass", which is constributed by Console.CHROME_CLASSES.
CHROME_CLASSESMap (object) of classNames used to populate the placeholders in the Console.HEADERTEMPLATE, Console.BODYTEMPLATE, and Console.FOOTER_TEMPLATE markup when rendering the Console UI.
By default, the keys contained in the object are:
ENTRY_CLASSESMap (object) of classNames used to populate the placeholders in the Console.ENTRY_TEMPLATE markup when rendering a new Console entry.
By default, the keys contained in the object are:
ENTRY_TEMPLATEDefault markup template used to create the DOM structure for Console entries. The markup contains {placeholder}s for content and classes that are replaced via Y.Lang.sub. The default template contains the {placeholder}s identified in Console.ENTRY_CLASSES as well as the following placeholders that will be populated by the log entry data:
FOOTER_TEMPLATEMarkup template used to generate the DOM structure for the footer section of the Console when it is rendered. The template includes many of the {placeholder}s from Console.CHROME_CLASSES as well as:
HEADER_TEMPLATEMarkup template used to generate the DOM structure for the header section of the Console when it is rendered. The template includes these {placeholder}s:
LOG_LEVEL_ERRORStatic identifier for logLevel configuration setting to allow only incoming messages of logLevel "error" to generate Console entries.
LOG_LEVEL_INFOStatic identifier for logLevel configuration setting to allow all incoming messages to generate Console entries.
LOG_LEVEL_WARNStatic identifier for logLevel configuration setting to allow only incoming messages of logLevel "warn" or "error" to generate Console entries.
collapsedControls the collapsed state of the Console
Default: false
collapsedChange
Fires when the value for the configuration attribute collapsed is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
consoleLimitMaximum number of Console entries allowed in the Console body at one time. This is used to keep acquired messages from exploding the DOM tree and impacting page performance.
Default: 300
consoleLimitChange
Fires when the value for the configuration attribute consoleLimit is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
defaultCategoryIf a category is not specified in the Y.log(..) statement, this category will be used. Categories "info", "warn", and "error" are also called log level.
Default: "info"
defaultCategoryChange
Fires when the value for the configuration attribute defaultCategory is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
defaultSourceIf a source is not specified in the Y.log(..) statement, this source will be used.
Default: "global"
defaultSourceChange
Fires when the value for the configuration attribute defaultSource is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
entryTemplateMarkup template used to create the DOM structure for Console entries.
Default: Console.ENTRY_TEMPLATE
entryTemplateChange
Fires when the value for the configuration attribute entryTemplate is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
heightString with units, or number, representing the height of the Console, inclusive of header and footer. If a number is provided, the default unit, defined by Widget's DEF_UNIT, property is used.
Default: "300px"
heightChange
Fires when the value for the configuration attribute height is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
lastTimeThe precise time the last entry was logged. Used to measure elapsed time between log messages.
Default: The moment the console module is <code>use</code>d
lastTimeChange
Fires when the value for the configuration attribute lastTime is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
logEventName of the custom event that will communicate log messages.
Default: "yui:log"
logEventChange
Fires when the value for the configuration attribute logEvent is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
logLevelMinimum entry log level to render into the Console. The initial logLevel value for all Console instances defaults from the Y.config.logLevel YUI configuration, or Console.LOGLEVELINFO if that configuration is not set.
Possible values are "info", "warn", "error" (case insensitive), or their corresponding statics Console.LOGLEVELINFO and so on.
Default: Y.config.logLevel or Console.LOG_LEVEL_INFO
logLevelChange
Fires when the value for the configuration attribute logLevel is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
logSourceObject that will emit the log events. By default the YUI instance. To have a single Console capture events from all YUI instances, set this to the Y.Global object.
Default: Y
logSourceChange
Fires when the value for the configuration attribute logSource is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
newestOnTopNew entries should display at the top of the Console or the bottom?
Default: true
newestOnTopChange
Fires when the value for the configuration attribute newestOnTop is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
pausedBoolean to pause the outputting of new messages to the console. When paused, messages will accumulate in the buffer.
Default: false
pausedChange
Fires when the value for the configuration attribute paused is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
printLimitMaximum number of entries printed in each iteration of the print loop. This is used to prevent excessive logging locking the page UI.
Default: 50
printLimitChange
Fires when the value for the configuration attribute printLimit is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
printTimeoutMillisecond timeout between iterations of the print loop, moving entries from the buffer to the UI.
Default: 100
printTimeoutChange
Fires when the value for the configuration attribute printTimeout is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
scrollIntoViewWhen new entries are added to the Console UI, should they be scrolled into view?
Default: true
scrollIntoViewChange
Fires when the value for the configuration attribute scrollIntoView is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
startTimeThe baseline time for this Console instance, used to measure elapsed
time from the moment the console module is used to the
moment each new entry is logged (not rendered).
This value is reset by the instance method myConsole.reset().
Default: The moment the console module is <code>use</code>d
startTimeChange
Fires when the value for the configuration attribute startTime is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
stringsCollection of strings used to label elements in the Console UI. Default collection contains the following name:value pairs:
stringsChange
Fires when the value for the configuration attribute strings is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
styleAllows the Console to flow in the document. Available values are 'inline', 'block', and 'separate' (the default).
Default: 'separate'
styleChange
Fires when the value for the configuration attribute style is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
useBrowserConsolePass through to the YUI instance useBrowserConsole configuration. By default this is set to false, which will disable logging to the browser console when a Console instance is created. If the logSource is not a YUI instance, this has no effect.
Default: false
useBrowserConsoleChange
Fires when the value for the configuration attribute useBrowserConsole is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
widthString with units, or number, representing the width of the Console. If a number is provided, the default unit, defined by Widget's DEF_UNIT, property is used.
Default: "300px"
widthChange
Fires when the value for the configuration attribute width is
changed. You can listen for the event using the on method if you
wish to be notified before the attribute's value has changed, or
using the after method if you wish to be notified after the
attribute's value has changed.
e
EventFacade
entryTransfers a received message to the print loop buffer. Default behavior defined in _defEntryFn.
event
Event.Facade
An Event Facade object with the following attribute specific properties added:
resetTriggers the reset behavior via the default logic in _defResetFn.
event
Event.Facade
Event Facade object