diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-07-07 19:19:00 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-07-07 19:19:00 +0900 |
| commit | aa4ef6745ad798bd7d4f05cb397ef1dd85279814 (patch) | |
| tree | d34ded516f52b91c4ff1a5443776ce22d8f483f0 /src/utils/logger.ts | |
| parent | Refactorijg (diff) | |
| download | sharkey-aa4ef6745ad798bd7d4f05cb397ef1dd85279814.tar.gz sharkey-aa4ef6745ad798bd7d4f05cb397ef1dd85279814.tar.bz2 sharkey-aa4ef6745ad798bd7d4f05cb397ef1dd85279814.zip | |
Refactorng
Diffstat (limited to 'src/utils/logger.ts')
| -rw-r--r-- | src/utils/logger.ts | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/utils/logger.ts b/src/utils/logger.ts deleted file mode 100644 index fae1042c39..0000000000 --- a/src/utils/logger.ts +++ /dev/null @@ -1,53 +0,0 @@ -import chalk, { Chalk } from 'chalk'; - -export type LogLevel = 'Error' | 'Warn' | 'Info'; - -function toLevelColor(level: LogLevel): Chalk { - switch (level) { - case 'Error': return chalk.red; - case 'Warn': return chalk.yellow; - case 'Info': return chalk.blue; - } -} - -export default class Logger { - private domain: string; - - constructor(domain: string) { - this.domain = domain; - } - - public static log(level: LogLevel, message: string): void { - const color = toLevelColor(level); - const time = (new Date()).toLocaleTimeString('ja-JP'); - console.log(`[${time} ${color.bold(level.toUpperCase())}]: ${message}`); - } - - public static error(message: string): void { - Logger.log('Error', message); - } - - public static warn(message: string): void { - Logger.log('Warn', message); - } - - public static info(message: string): void { - Logger.log('Info', message); - } - - public log(level: LogLevel, message: string): void { - Logger.log(level, `[${this.domain}] ${message}`); - } - - public error(message: string): void { - this.log('Error', message); - } - - public warn(message: string): void { - this.log('Warn', message); - } - - public info(message: string): void { - this.log('Info', message); - } -} |