Add server state change events into the console log
This commit is contained in:
parent
0108035c05
commit
8599e2c64b
1 changed files with 7 additions and 1 deletions
|
@ -49,6 +49,10 @@ export default () => {
|
|||
'\u001b[1m\u001b[41m[Internal] ' + line.replace(/(?:\r\n|\r|\n)$/im, '') + '\u001b[0m',
|
||||
);
|
||||
|
||||
const handlePowerChangeEvent = (state: string) => terminal.writeln(
|
||||
'\u001b[1m\u001b[33m[Status Change] Server marked as ' + state + '...\u001b[0m',
|
||||
);
|
||||
|
||||
const handleCommandKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key !== 'Enter' || (e.key === 'Enter' && e.currentTarget.value.length < 1)) {
|
||||
return;
|
||||
|
@ -72,6 +76,7 @@ export default () => {
|
|||
if (connected && instance) {
|
||||
terminal.clear();
|
||||
|
||||
instance.addListener('status', handlePowerChangeEvent);
|
||||
instance.addListener('console output', handleConsoleOutput);
|
||||
instance.addListener('daemon error', handleDaemonErrorOutput);
|
||||
instance.send('send logs');
|
||||
|
@ -79,7 +84,8 @@ export default () => {
|
|||
|
||||
return () => {
|
||||
instance && instance.removeListener('console output', handleConsoleOutput)
|
||||
.removeListener('daemon error', handleDaemonErrorOutput);
|
||||
.removeListener('daemon error', handleDaemonErrorOutput)
|
||||
.removeListener('status', handlePowerChangeEvent);
|
||||
};
|
||||
}, [ connected, instance ]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue