From a79931f85af1dcc1f460e06b9c5317938055d585 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 15 May 2018 10:33:59 +1000 Subject: [PATCH] docs(web-multi-logger): add doc comments for js API site --- packages/utils/web-multi-logger/src/Logger.ts | 10 ++++++++++ packages/utils/web-multi-logger/src/Tab.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/packages/utils/web-multi-logger/src/Logger.ts b/packages/utils/web-multi-logger/src/Logger.ts index 7886b22b91..3e2878aca3 100644 --- a/packages/utils/web-multi-logger/src/Logger.ts +++ b/packages/utils/web-multi-logger/src/Logger.ts @@ -26,18 +26,28 @@ export default class Logger { (this.app as any).ws('/sub', () => {}); } + /** + * Creates a new tab with the given name, the name should be human readable + * it will be used as the tab title in the front end. + */ createTab(name: string) { const tab = new Tab(name, this.ws); this.tabs.push(tab); return tab; } + /** + * Start the HTTP server hosting the web UI + */ start() { return new Promise((resolve) => { this.server = this.app.listen(this.port, () => resolve(this.port)); }); } + /** + * Stop the HTTP server hosting the web UI + */ stop() { if (this.server) this.server.close(); } diff --git a/packages/utils/web-multi-logger/src/Tab.ts b/packages/utils/web-multi-logger/src/Tab.ts index b6bcd153de..caad08bf6c 100644 --- a/packages/utils/web-multi-logger/src/Tab.ts +++ b/packages/utils/web-multi-logger/src/Tab.ts @@ -13,6 +13,9 @@ export default class Tab { idCounter += 1; } + /** + * Log a line to the web UI, a new line is automatically appended to the line + */ log(line: string) { const log = new Log(line, new Date()); this.logs.push(log);