2024-02-02 00:35:43 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-04-10 02:43:44 +00:00
|
|
|
// This module is browser compatible.
|
2024-02-02 00:35:43 +00:00
|
|
|
|
|
|
|
import { getLogger } from "./get_logger.ts";
|
2024-02-27 21:57:25 +00:00
|
|
|
import type { GenericFunction } from "./logger.ts";
|
2024-02-02 00:35:43 +00:00
|
|
|
|
|
|
|
/** Log with critical level, using default logger. */
|
|
|
|
export function critical<T>(msg: () => T, ...args: unknown[]): T | undefined;
|
|
|
|
export function critical<T>(
|
|
|
|
msg: T extends GenericFunction ? never : T,
|
|
|
|
...args: unknown[]
|
|
|
|
): T;
|
|
|
|
export function critical<T>(
|
|
|
|
msg: (T extends GenericFunction ? never : T) | (() => T),
|
|
|
|
...args: unknown[]
|
|
|
|
): T | undefined {
|
|
|
|
// Assist TS compiler with pass-through generic type
|
|
|
|
if (msg instanceof Function) {
|
|
|
|
return getLogger("default").critical(msg, ...args);
|
|
|
|
}
|
|
|
|
return getLogger("default").critical(msg, ...args);
|
|
|
|
}
|