summaryrefslogtreecommitdiff
path: root/std/log/logger.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/log/logger.ts')
-rw-r--r--std/log/logger.ts34
1 files changed, 18 insertions, 16 deletions
diff --git a/std/log/logger.ts b/std/log/logger.ts
index d1e1d9755..c00ab78ec 100644
--- a/std/log/logger.ts
+++ b/std/log/logger.ts
@@ -1,12 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import {
- LogLevels,
- getLevelByName,
- getLevelName,
-} from "./levels.ts";
+import { LogLevels, getLevelByName, getLevelName } from "./levels.ts";
import type { LevelName } from "./levels.ts";
import type { BaseHandler } from "./handlers.ts";
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export type GenericFunction = (...args: any[]) => any;
+
export interface LogRecordOptions {
msg: string;
args: unknown[];
@@ -91,7 +90,7 @@ export class Logger {
*/
private _log<T>(
level: number,
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
if (this.level > level) {
@@ -139,45 +138,48 @@ export class Logger {
}
debug<T>(msg: () => T, ...args: unknown[]): T | undefined;
- debug<T>(msg: T extends Function ? never : T, ...args: unknown[]): T;
+ debug<T>(msg: T extends GenericFunction ? never : T, ...args: unknown[]): T;
debug<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
return this._log(LogLevels.DEBUG, msg, ...args);
}
info<T>(msg: () => T, ...args: unknown[]): T | undefined;
- info<T>(msg: T extends Function ? never : T, ...args: unknown[]): T;
+ info<T>(msg: T extends GenericFunction ? never : T, ...args: unknown[]): T;
info<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
return this._log(LogLevels.INFO, msg, ...args);
}
warning<T>(msg: () => T, ...args: unknown[]): T | undefined;
- warning<T>(msg: T extends Function ? never : T, ...args: unknown[]): T;
+ warning<T>(msg: T extends GenericFunction ? never : T, ...args: unknown[]): T;
warning<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
return this._log(LogLevels.WARNING, msg, ...args);
}
error<T>(msg: () => T, ...args: unknown[]): T | undefined;
- error<T>(msg: T extends Function ? never : T, ...args: unknown[]): T;
+ error<T>(msg: T extends GenericFunction ? never : T, ...args: unknown[]): T;
error<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
return this._log(LogLevels.ERROR, msg, ...args);
}
critical<T>(msg: () => T, ...args: unknown[]): T | undefined;
- critical<T>(msg: T extends Function ? never : T, ...args: unknown[]): T;
critical<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: T extends GenericFunction ? never : T,
+ ...args: unknown[]
+ ): T;
+ critical<T>(
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
return this._log(LogLevels.CRITICAL, msg, ...args);