debug log.

This commit is contained in:
Christopher Jeffrey 2015-04-04 02:23:43 -07:00
parent 7afb791950
commit bb4a8c82aa
3 changed files with 26 additions and 17 deletions

View File

@ -10,7 +10,12 @@
process.title = 'multiplex.js';
var blessed = require('blessed')
, screen = blessed.screen();
, screen;
screen = blessed.screen({
smartCSR: true,
log: process.env.HOME + '/blessed-terminal.log'
});
var left = blessed.terminal({
parent: screen,
@ -33,6 +38,10 @@ var left = blessed.terminal({
}
});
left.pty.on('data', function(data) {
screen.log(JSON.stringify(data));
});
var right = blessed.terminal({
parent: screen,
cursor: 'block',

View File

@ -474,7 +474,7 @@ Screen.prototype.leave = function() {
Screen.prototype.postEnter = function() {
var self = this;
if (this.options.debug) {
this._debugLog = new Log({
this.debugLog = new Log({
parent: this,
hidden: true,
draggable: true,
@ -504,34 +504,34 @@ Screen.prototype.postEnter = function() {
}
});
this._debugLog._.toggle = function() {
if (self._debugLog.hidden) {
this.debugLog.toggle = function() {
if (self.debugLog.hidden) {
self.saveFocus();
self._debugLog.show();
self._debugLog.setFront();
self._debugLog.focus();
self.debugLog.show();
self.debugLog.setFront();
self.debugLog.focus();
} else {
self._debugLog.hide();
self.debugLog.hide();
self.restoreFocus();
}
self.render();
};
this._debugLog.key(['q', 'escape'], self._debugLog._.toggle);
this.key('f12', self._debugLog._.toggle);
this.debugLog.key(['q', 'escape'], self.debugLog.toggle);
this.key('f12', self.debugLog.toggle);
}
};
Screen.prototype.log = function() {
if (this._debugLog) {
this._debugLog.log.apply(this._debugLog, arguments);
if (this.debugLog) {
this.debugLog.log.apply(this.debugLog, arguments);
}
return this.program.log.apply(this.program, arguments);
};
Screen.prototype.debug = function() {
if (this._debugLog) {
this._debugLog.log.apply(this._debugLog, arguments);
if (this.debugLog) {
this.debugLog.log.apply(this.debugLog, arguments);
}
return this.program.debug.apply(this.program, arguments);
};

View File

@ -14,13 +14,13 @@ screen = blessed.screen({
debug: true
});
screen._debugLog.parseTags = true;
screen.debugLog.parseTags = true;
var logs = '';
require('./tail')(__dirname + '/logs/widget.log').on('line', function(line) {
if (!screen._debugLog.hidden) return;
if (!screen.debugLog.hidden) return;
logs += line + '\n';
});
screen._debugLog.on('show', function() {
screen.debugLog.on('show', function() {
if (logs) {
screen.debug(logs);
logs = '';