mirror of
https://github.com/chjj/blessed.git
synced 2026-02-06 13:36:46 +00:00
debug log.
This commit is contained in:
parent
7afb791950
commit
bb4a8c82aa
@ -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',
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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 = '';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user