Add companion logging

Summary: Add top-level error logging to flipper-server. Use the top-level logging mechanism in flipper-companion.

Reviewed By: lblasa

Differential Revision: D36252218

fbshipit-source-id: 58d22b3b9bd51e597b5250478640f54d10277861
This commit is contained in:
Andrey Goncharov
2022-05-10 05:13:24 -07:00
committed by Facebook GitHub Bot
parent e218b79de2
commit 98dde53cda
4 changed files with 134 additions and 29 deletions

View File

@@ -14,6 +14,8 @@ import {
ExecResponseErrorWebSocketMessage,
ServerEventWebSocketMessage,
GenericWebSocketError,
UserError,
SystemError,
} from 'flipper-common';
import {FlipperServerImpl} from 'flipper-server-core';
import {WebSocketServer} from 'ws';
@@ -99,6 +101,20 @@ export function startSocketServer(
}
})
.catch((error: any) => {
if (error instanceof UserError) {
console.warn(
`flipper-server.startSocketServer.exec: ${error.message}`,
error.context,
error.stack,
);
}
if (error instanceof SystemError) {
console.error(
`flipper-server.startSocketServer.exec: ${error.message}`,
error.context,
error.stack,
);
}
if (connected) {
// TODO: Serialize error
// TODO: log if verbose console.warn('Failed to handle response', error);