// 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 warning level, using default logger. */
export function warn<T>(msg: () => T, ...args: unknown[]): T | undefined;
export function warn<T>(
  msg: T extends GenericFunction ? never : T,
  ...args: unknown[]
): T;
export function warn<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").warn(msg, ...args);
  }
  return getLogger("default").warn(msg, ...args);
}

// denoCacheMetadata={"headers":{"date":"Tue, 28 Jul 2026 12:31:15 GMT","cf-ray":"a223e65789d07db6-LAX","set-cookie":"__cf_bm=89XXUKD5k3vV0M5VL54pGjmtIPMVgEb8G2jdDulfHFs-1785241875.1264133-1.0.1.1-0OY3H4ZP4em37Sy9cunifxvIUyaB.fvvuIMeA9.YQX71x7RaLRUuRHFDsXiNwusstJ4jdlYgK_oRlo0eAxEoImXCsd.QoZaAZRdSk8sAH9qqUTbb2PrCEDrMeR6V2M.P; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","vary":"Origin","content-length":"758","access-control-allow-origin":"*","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';","cross-origin-resource-policy":"cross-origin","x-jsr-backend":"modules","cache-control":"public, max-age=31536000, immutable","x-content-type-options":"nosniff","x-robots-tag":"noindex","alt-svc":"h3=\":443\"; ma=86400","server":"cloudflare","content-type":"text/typescript","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=qZWp1dhGXK1CpEiN4ewoi4YSqzLee1CAHbawqIenDTmg9ZnutA3GIqK7wfA3DGPtVfmNDaXEc6E8%2FneRa83LfO2PSEYfs18Hf4nh1UOnn3abBWVXHBtGoRI%3D\"}]}","access-control-expose-headers":"*","etag":"\"4142e7fec43ed982c2756812ee15519b\""},"url":"https://jsr.io/@std/log/0.224.7/warn.ts","time":1785241875}