Allow switching between stdout and stderr logs in config.ts

This commit is contained in:
Kristóf Tóth 2018-05-28 16:36:19 +02:00
parent 0aa67b25aa
commit 1b8a36331c
5 changed files with 17 additions and 9 deletions

View File

@ -40,7 +40,7 @@ export const config = {
console: {
route: 'console',
defaultContent: '',
rewriteContentWithNewLogs: true
rewriteContentWithNewLogs: 'stdout'
},
testmessenger: {
route: 'testmessenger'

View File

@ -13,6 +13,7 @@ import { config } from '../config';
})
export class ConsoleComponent implements OnInit {
console_content: string = config.console.defaultContent;
rewriteContentWithNewLogs: string = config.console.rewriteContentWithNewLogs;
command_handlers = {
'write': this.writeHandler.bind(this),
@ -36,9 +37,12 @@ export class ConsoleComponent implements OnInit {
this.sendContent(this.console_content);
}
newLogHandler(content: string) {
if (config.console.rewriteContentWithNewLogs) {
this.setContent(content);
newLogHandler(logs: any) {
if (this.rewriteContentWithNewLogs !== '') {
const log = logs[this.rewriteContentWithNewLogs];
if (log) {
this.setContent(log);
}
}
}

View File

@ -102,8 +102,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.selectedTerminalMenuItem = item;
}
setConsoleContent(content: string) {
this.childConsole.newLogHandler(content);
setConsoleContent(logs: any) {
this.childConsole.newLogHandler(logs);
if (config.ide.showConsoleOnDeploy) {
this.selectTerminalMenuItem('console');
}

View File

@ -63,7 +63,7 @@ export class IdeComponent implements OnInit {
language: string = config.ide.defaultLanguage;
theme = 'cobalt';
@Output() newLog = new EventEmitter<string>();
@Output() newLog = new EventEmitter<any>();
options: any = {enableBasicAutocompletion: true,
enableSnippets: true,
@ -101,7 +101,10 @@ export class IdeComponent implements OnInit {
config.ide.deployProcessName,
(event) => {
this.deploymentNotificationService.deploying.next(false);
this.newLog.emit(event.data.log);
this.newLog.emit({
stdout: event.data.stdout,
stderr: event.data.stderr
});
}
);

View File

@ -5,5 +5,6 @@ export class ProcessCommand {
command: string;
process_name: string;
error?: string;
log: string;
stdout: string;
stderr: string;
}