console.js revision 60f5c306297c0d0dc6d239ee618ee333f4c40746
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney * Console creates a visualization for messages logged through calls to a YUI
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * instance's <code>Y.log( message, category, source )</code> method. The
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * debug versions of YUI modules will include logging statements to offer some
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * insight into the steps executed during that module's operation. Including
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * log statements in your code will cause those messages to also appear in the
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * Console. Use Console to aid in developing your page or application.
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * Entry categories "info", "warn", and "error"
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * are also referred to as the log level, and entries are filtered against the
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * configured logLevel.
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @module console
eaa9719567e2ec55d96f9298077f5fc0effe1ed3Satyen Desai * @class Console
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @extends Widget
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @param conf {Object} Configuration object (see Configuration attributes)
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @constructor
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai Console.superclass.constructor.apply(this,arguments);
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai C_CONSOLE_CONTROLS = getCN(CONSOLE,'controls'),
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai C_ENTRY_CONTENT = getCN(CONSOLE,ENTRY,'content'),
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney '<div class="{entry_class} {cat_class} {src_class}">'+
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai '<p class="{entry_meta_class}">'+
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney '<span class="{entry_src_class}">'+
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai '{sourceAndDetail}'+
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney '<span class="{entry_cat_class}">'+
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai '{label}</span>'+
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai '<span class="{entry_time_class}">'+
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai ' {totalTime}ms (+{elapsedTime}) {localTime}'+
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney '<pre class="{entry_content_class}">{message}</pre>'+
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * The identity of the widget.
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney * @property Console.NAME
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @type String
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * Static identifier for logLevel configuration setting to allow all
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * incoming messages to generate Console entries.
982119a5f53b6531610b5d29c631550a6222da1fSatyen Desai * @property Console.LOG_LEVEL_INFO
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @type String
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney * Static identifier for logLevel configuration setting to allow only
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * incoming messages of logLevel "warn" or "error"
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * to generate Console entries.
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @property Console.LOG_LEVEL_WARN
57775f39a19dc392e5882d5217d5a9148688aa4aMatt Sweeney * @type String
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * Static identifier for logLevel configuration setting to allow only
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * incoming messages of logLevel "error" to generate
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * Console entries.
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @property Console.LOG_LEVEL_ERROR
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @type String
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * Map (object) of classNames used to populate the placeholders in the
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * Console.ENTRY_TEMPLATE markup when rendering a new Console entry.
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * <p>By default, the keys contained in the object are:</p>
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * <li>entry_class</li>
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * <li>entry_meta_class</li>
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * <li>entry_cat_class</li>
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * <li>entry_src_class</li>
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * <li>entry_time_class</li>
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * <li>entry_content_class</li>
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @property Console.ENTRY_CLASSES
69ce664b1e66d48ae3ae5be08488f38b4855fc8bSatyen Desai * @type Object
CHROME_CLASSES : {
ATTRS : {
logEvent : {
writeOnce : true,
logSource : {
value : Y,
writeOnce : true,
validator : function (v) {
strings : {
value : {
paused : {
value : false,
defaultCategory : {
defaultSource : {
entryTemplate : {
* Y.config.logLevel YUI configuration, or Console.LOG_LEVEL_INFO if
* @default Y.config.logLevel or Console.LOG_LEVEL_INFO
logLevel : {
setter : function (v) {
return this._setLogLevel(v);
printTimeout : {
printLimit : {
consoleLimit : {
newestOnTop : {
value : true
scrollIntoView : {
value : true
startTime : {
value : new Date()
lastTime : {
value : new Date(),
readOnly: true
collapsed : {
value : false
height: {
width: {
lazyAdd: false,
value: false,
getter : function () {
setter : function (v) {
_evtCat : null,
_head : null,
_body : null,
_foot : null,
_printLoop : null,
buffer : null,
log : function () {
clearConsole : function () {
this._cancelPrintLoop();
this.buffer = [];
reset : function () {
collapse : function () {
expand : function () {
entries = [],
this._cancelPrintLoop();
if (newestOnTop) {
this.scrollToLatest();
this._trimOldEntries();
initializer : function () {
this.buffer = [];
* @param event {Event.Facade} An Event Facade object with the following attribute specific properties added:
destructor : function () {
this._cancelPrintLoop();
renderUI : function () {
this._initHead();
this._initBody();
this._initFoot();
syncUI : function () {
bindUI : function () {
this._afterStringsChange);
this._afterPausedChange);
this._afterConsoleLimitChange);
this._afterCollapsedChange);
_initHead : function () {
_initBody : function () {
_initFoot : function () {
_isInLogLevel : function (e) {
_normalizeMessage : function (e) {
time : new Date(),
source : null,
label : null,
localTime : null,
elapsedTime : null,
totalTime : null
_schedulePrint : function () {
this, this.printBuffer,
_createEntryHTML : function (m) {
m = merge(
this._htmlEscapeMessage(m),
function (_,token) {
scrollToLatest : function () {
_htmlEscapeMessage : function (m) {
m = Y.clone(m);
_trimOldEntries : function () {
entries,e,i,l;
if (bd) {
i = limit;
e.remove();
_encodeHTML : function (s) {
return isString(s) ?
_cancelPrintLoop : function () {
if (this._printLoop) {
this._printLoop = null;
_onPauseClick : function (e) {
_onClearClick : function (e) {
this.clearConsole();
_onCollapseClick : function (e) {
_setLogLevel : function (v) {
if (isString(v)) {
v = v.toLowerCase();
* 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.
_uiSetHeight : function (v) {
_afterStringsChange : function (e) {
el;
if (el) {
if (el) {
if (el) {
_afterPausedChange : function (e) {
if (!paused) {
this._schedulePrint();
} else if (this._printLoop) {
this._cancelPrintLoop();
if (node) {
_afterConsoleLimitChange : function () {
this._trimOldEntries();
_afterCollapsedChange : function (e) {
_uiUpdateCollapsed : function (v) {
if (button) {
_afterVisibleChange : function (e) {
_uiUpdateFromHideShow : function (v) {
_onLogEvent : function (e) {
_defResetFn : function () {
this.clearConsole();
_defEntryFn : function (e) {
if (e.message) {
this._schedulePrint();