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

// denoCacheMetadata={"headers":{"cache-control":"public, max-age=31536000, immutable","vary":"Origin","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=bcLHHDEhATbGs8GD%2BejY4ZAo2k8458SmXM0DXJCbIPC848GJxAKs4QwIbsaqdCWowlqC07b5jHgYtv1Z9ZUCMxxmB8bQg5A8fnKrZLeVV%2FR6cGX6CSDI9TM%3D\"}]}","x-content-type-options":"nosniff","content-length":"761","x-jsr-backend":"modules","server":"cloudflare","etag":"\"1203a84b077d296e8b84a89ba6f51651\"","access-control-expose-headers":"*","content-type":"text/typescript","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","cross-origin-resource-policy":"cross-origin","access-control-allow-origin":"*","set-cookie":"__cf_bm=k8kkTQijK_2g4MmHWHmcnZMMmjq5Tn0Z4E7oAYo5b_8-1785241875.1109796-1.0.1.1-fn8B9ZU3X.K.IDCjyW4FryDYw60e9nlPnVQkW043VOksD8R30sMoxlzwWABWlEjvloV2KT5J4HN2wcE3OrSM7HOhse4bWGGbuwujasToMyvY2juIwLcDTJSESrLxL._P; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","cf-ray":"a223e657699d7db6-LAX","x-robots-tag":"noindex","alt-svc":"h3=\":443\"; ma=86400","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';","date":"Tue, 28 Jul 2026 12:31:15 GMT"},"url":"https://jsr.io/@std/log/0.224.7/debug.ts","time":1785241875}