Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davglass/184754 to your computer and use it in GitHub Desktop.
Save davglass/184754 to your computer and use it in GitHub Desktop.
Y.Console.prototype.printBuffer = function (limit) {
var messages = this.buffer,
debug = Y.config.debug,
entries = Y.Node.create('div'),
consoleLimit= this.get('consoleLimit'),
newestOnTop = this.get('newestOnTop'),
anchor = newestOnTop ? this._body.get('firstChild') : null,
method = newestOnTop ? "prepend" : "append",
message,
entry,
i;
if (messages.length > consoleLimit) {
messages.splice(0, messages.length - consoleLimit);
}
limit = Math.min(messages.length, (limit || messages.length));
// turn off logging system
Y.config.debug = false;
if (!this.get(PAUSED) && this.get('rendered')) {
for (i = 0; i < limit && messages.length; ++i) {
message = messages.shift();
entries[method](messages.node || this._createEntryHTML(message));
}
if (!messages.length) {
this._cancelPrintLoop();
}
entries = entries.children();
if (entries.size()) {
this._body.insertBefore(entries.toFrag(), anchor);
if (this.get('scrollIntoView')) {
this.scrollToLatest();
}
this._trimOldEntries();
}
}
// restore logging system
Y.config.debug = debug;
return this;
};
var yconsole = new Y.Console({
on: {
entry: function (e) {
var n = Y.Node.create(YOUR STUFF);
n.on(eventName, handler);
e.message.node = n;
}
}
}).render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment