summaryrefslogtreecommitdiff
path: root/std/log
diff options
context:
space:
mode:
Diffstat (limited to 'std/log')
-rw-r--r--std/log/logger.ts34
-rw-r--r--std/log/mod.ts21
2 files changed, 29 insertions, 26 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);
diff --git a/std/log/mod.ts b/std/log/mod.ts
index 10feb04b1..512de534b 100644
--- a/std/log/mod.ts
+++ b/std/log/mod.ts
@@ -1,5 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { Logger } from "./logger.ts";
+import type { GenericFunction } from "./logger.ts";
import {
BaseHandler,
ConsoleHandler,
@@ -76,11 +77,11 @@ export function getLogger(name?: string): Logger {
export function debug<T>(msg: () => T, ...args: unknown[]): T | undefined;
export function debug<T>(
- msg: T extends Function ? never : T,
+ msg: T extends GenericFunction ? never : T,
...args: unknown[]
): T;
export function debug<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
// Assist TS compiler with pass-through generic type
@@ -92,11 +93,11 @@ export function debug<T>(
export function info<T>(msg: () => T, ...args: unknown[]): T | undefined;
export function info<T>(
- msg: T extends Function ? never : T,
+ msg: T extends GenericFunction ? never : T,
...args: unknown[]
): T;
export function info<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
// Assist TS compiler with pass-through generic type
@@ -108,11 +109,11 @@ export function info<T>(
export function warning<T>(msg: () => T, ...args: unknown[]): T | undefined;
export function warning<T>(
- msg: T extends Function ? never : T,
+ msg: T extends GenericFunction ? never : T,
...args: unknown[]
): T;
export function warning<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
// Assist TS compiler with pass-through generic type
@@ -124,11 +125,11 @@ export function warning<T>(
export function error<T>(msg: () => T, ...args: unknown[]): T | undefined;
export function error<T>(
- msg: T extends Function ? never : T,
+ msg: T extends GenericFunction ? never : T,
...args: unknown[]
): T;
export function error<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
// Assist TS compiler with pass-through generic type
@@ -140,11 +141,11 @@ export function error<T>(
export function critical<T>(msg: () => T, ...args: unknown[]): T | undefined;
export function critical<T>(
- msg: T extends Function ? never : T,
+ msg: T extends GenericFunction ? never : T,
...args: unknown[]
): T;
export function critical<T>(
- msg: (T extends Function ? never : T) | (() => T),
+ msg: (T extends GenericFunction ? never : T) | (() => T),
...args: unknown[]
): T | undefined {
// Assist TS compiler with pass-through generic type