// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { getLogger } from "./get_logger.ts";
import type { GenericFunction } from "./logger.ts";

/** 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);
}

// denoCacheMetadata={"headers":{"x-content-type-options":"nosniff","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","alt-svc":"h3=\":443\"; ma=86400","etag":"\"22dfa0dcdba14faf12b321ed7a29ee0b\"","access-control-expose-headers":"*","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","server":"cloudflare","set-cookie":"__cf_bm=A8iATPZSo2hlJbnVAcVk0nwpuV2Bi1CJYuqz6eD9Ejo-1785241875.110709-1.0.1.1-aacPM3TF3DYsERu.Dp07d1OPQ98Clyz.W.izQ602A5bmzOT1Ic7c7M1c49HJGmdzEKA81NiYI0dlejT9C0XkxQ2TCD6t.JjRLAuQIhHG7N5885N6bgaPZieA3McOv3i2; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","cache-control":"public, max-age=31536000, immutable","x-jsr-backend":"modules","cross-origin-resource-policy":"cross-origin","content-length":"779","content-type":"text/typescript","cf-ray":"a223e657699b7db6-LAX","date":"Tue, 28 Jul 2026 12:31:15 GMT","x-robots-tag":"noindex","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=LU98bmXyIbqlZ%2Fk34gKe6Qr82kLN58u8tOFdfUqAnB21OqcnrCp7hbe7Uq7KStkwpVXMinXt8ZFZiVv1euKJ3Qx%2BInF6uhm5yVahlHn8itiJVfAPvdBqdJg%3D\"}]}","access-control-allow-origin":"*","vary":"Origin"},"url":"https://jsr.io/@std/log/0.224.7/critical.ts","time":1785241875}