mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
feat(frontend): colorize terminal output of logger
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
1f0439b618
commit
94cf510736
4 changed files with 16 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
import { isDevMode, isTestMode } from './test-modes'
|
||||
import { DateTime } from 'luxon'
|
||||
import pico from 'picocolors'
|
||||
|
||||
/**
|
||||
* Simple logger that prefixes messages with a timestamp and a name.
|
||||
|
@ -70,6 +71,11 @@ export class Logger {
|
|||
|
||||
private prefix(): string[] {
|
||||
const timestamp = DateTime.now().toFormat('yyyy-MM-dd HH:mm:ss')
|
||||
return [`%c[${timestamp}] %c(${this.scope})`, 'color: yellow', 'color: orange']
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
return [pico.yellow(`[${timestamp}]`), pico.green(`(${this.scope})`)]
|
||||
} else {
|
||||
return [`%c[${timestamp}] %c(${this.scope})`, 'color: yellow', 'color: green']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue