summaryrefslogtreecommitdiff
path: root/std/log/logger.ts
diff options
context:
space:
mode:
authorChristopher Dieringer <cdaringe@users.noreply.github.com>2020-04-25 02:13:26 -0700
committerGitHub <noreply@github.com>2020-04-25 11:13:26 +0200
commitb28e60ecaf5d48c36cb435361834f4884d9451c2 (patch)
treebc4fd6aa37ba3cd931ff29d259a05f8126202f34 /std/log/logger.ts
parentf8d83361cd11d3aa42333171ecb6b129fdcbefeb (diff)
refactor(std/log): support enum log level (#4859)
Diffstat (limited to 'std/log/logger.ts')
-rw-r--r--std/log/logger.ts21
1 files changed, 13 insertions, 8 deletions
diff --git a/std/log/logger.ts b/std/log/logger.ts
index 9653d9008..6a12325e8 100644
--- a/std/log/logger.ts
+++ b/std/log/logger.ts
@@ -1,5 +1,10 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { LogLevel, getLevelByName, getLevelName } from "./levels.ts";
+import {
+ LogLevels,
+ getLevelByName,
+ getLevelName,
+ LevelName,
+} from "./levels.ts";
import { BaseHandler } from "./handlers.ts";
export class LogRecord {
@@ -26,11 +31,11 @@ export class LogRecord {
export class Logger {
level: number;
- levelName: string;
+ levelName: LevelName;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
handlers: any[];
- constructor(levelName: string, handlers?: BaseHandler[]) {
+ constructor(levelName: LevelName, handlers?: BaseHandler[]) {
this.level = getLevelByName(levelName);
this.levelName = levelName;
@@ -48,22 +53,22 @@ export class Logger {
}
debug(msg: string, ...args: unknown[]): void {
- this._log(LogLevel.DEBUG, msg, ...args);
+ this._log(LogLevels.DEBUG, msg, ...args);
}
info(msg: string, ...args: unknown[]): void {
- this._log(LogLevel.INFO, msg, ...args);
+ this._log(LogLevels.INFO, msg, ...args);
}
warning(msg: string, ...args: unknown[]): void {
- this._log(LogLevel.WARNING, msg, ...args);
+ this._log(LogLevels.WARNING, msg, ...args);
}
error(msg: string, ...args: unknown[]): void {
- this._log(LogLevel.ERROR, msg, ...args);
+ this._log(LogLevels.ERROR, msg, ...args);
}
critical(msg: string, ...args: unknown[]): void {
- this._log(LogLevel.CRITICAL, msg, ...args);
+ this._log(LogLevels.CRITICAL, msg, ...args);
}
}