From 050089e76b2648876c5183ac05736ccdbefe3535 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Wed, 30 Oct 2019 22:28:34 -0400 Subject: [PATCH] Update the log prompt title to include the full date --- packages/logconsole/src/widget.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/logconsole/src/widget.ts b/packages/logconsole/src/widget.ts index be3fbdcfe307..ecfaba92f705 100644 --- a/packages/logconsole/src/widget.ts +++ b/packages/logconsole/src/widget.ts @@ -49,15 +49,26 @@ class LogConsoleOutputPrompt extends Widget implements IOutputPrompt { * Date & time when output is logged. */ set timestamp(value: Date) { - this._timestampNode.innerHTML = value.toLocaleTimeString(); + this._timestamp = value; + this._timestampNode.innerHTML = this._timestamp.toLocaleTimeString(); + this.update(); } /** * Log level */ set level(value: FullLogLevel) { + this._level = value; this.node.dataset.logLevel = value; - this.node.title = `${toTitleCase(value)} message`; + this.update(); + } + + update() { + if (this._level !== undefined && this._timestamp !== undefined) { + this.node.title = `${this._timestamp.toLocaleString()}; ${toTitleCase( + this._level + )} level`; + } } /** @@ -65,6 +76,8 @@ class LogConsoleOutputPrompt extends Widget implements IOutputPrompt { */ executionCount: nbformat.ExecutionCount; + private _timestamp: Date; + private _level: FullLogLevel; private _timestampNode: HTMLDivElement; }