feat(console): print console results as log so cockpit gets it

This commit is contained in:
Jonathan Rainville 2019-02-26 12:03:01 -05:00
parent e3396417da
commit 57cd6d3da1
4 changed files with 9 additions and 5 deletions

View File

@ -342,7 +342,8 @@ class EmbarkController {
new REPL({ new REPL({
events: engine.events, events: engine.events,
env: engine.env, env: engine.env,
ipc: engine.ipc ipc: engine.ipc,
logger: engine.logger
}).start(callback); }).start(callback);
} }
], function (err, _result) { ], function (err, _result) {

View File

@ -25,7 +25,7 @@ class Dashboard {
start(done) { start(done) {
let monitor; let monitor;
monitor = new Monitor({env: this.env, events: this.events, version: this.version, ipc: this.ipc}); monitor = new Monitor({env: this.env, events: this.events, version: this.version, ipc: this.ipc, logger: this.logger});
this.logger.logFunction = monitor.logEntry; this.logger.logFunction = monitor.logEntry;
let plugin = this.plugins.createPlugin('dashboard', {}); let plugin = this.plugins.createPlugin('dashboard', {});
plugin.registerAPICall( plugin.registerAPICall(

View File

@ -11,6 +11,7 @@ class Monitor {
this.color = options.color || "green"; this.color = options.color || "green";
this.minimal = options.minimal || false; this.minimal = options.minimal || false;
this.ipc = options.ipc; this.ipc = options.ipc;
this.logger = options.logger;
this.screen = blessed.screen({ this.screen = blessed.screen({
smartCSR: true, smartCSR: true,
@ -52,6 +53,7 @@ class Monitor {
this.repl = new REPL({ this.repl = new REPL({
events: this.events, events: this.events,
env: this.env, env: this.env,
logger: this.logger,
inputStream: this.terminalReadableStream, inputStream: this.terminalReadableStream,
outputStream: terminalWritableStream, outputStream: terminalWritableStream,
logText: this.logText, logText: this.logText,

View File

@ -9,6 +9,7 @@ class REPL {
this.outputStream = options.outputStream || process.stdout; this.outputStream = options.outputStream || process.stdout;
this.logText = options.logText; this.logText = options.logText;
this.ipc = options.ipc; this.ipc = options.ipc;
this.logger = options.logger;
} }
addHistory(cmd) { addHistory(cmd) {
@ -18,9 +19,9 @@ class REPL {
} }
} }
enhancedEval(cmd, context, filename, callback) { enhancedEval(cmd, _context, _filename, _callback) {
this.events.request('console:executeCmd', cmd.trim(), function (err, message) { this.events.request('console:executeCmd', cmd.trim(), (err, message) => {
callback(err, message === undefined ? '' : message); // This way, we don't print undefined this.logger.info(message === undefined ? '' : message);
}); });
} }