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

// denoCacheMetadata={"headers":{"content-type":"text/typescript","cross-origin-resource-policy":"cross-origin","x-jsr-backend":"modules","set-cookie":"__cf_bm=OhFHz8F_acCSkOhq1pcxAVmStcfYsYc_x3UR7Qediss-1785241875.1253042-1.0.1.1-nUtsniA9RS76nwfmS1HuD.MtSf9nCAirmBYo8FU.5mkU5rT0OSZAC3127ddZjizRT0X_uYhv4.6sbzEZqhf3VH.xeU9iOBuyXGzwSojTpWfESzY4z75H5UZIPbMBV_B2; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","cf-ray":"a223e65789c77db6-LAX","server":"cloudflare","access-control-expose-headers":"*","x-content-type-options":"nosniff","access-control-allow-origin":"*","cache-control":"public, max-age=31536000, immutable","x-robots-tag":"noindex","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';","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","alt-svc":"h3=\":443\"; ma=86400","date":"Tue, 28 Jul 2026 12:31:15 GMT","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=kZjBI3sw%2BQFDVzt1WUr8gywL37qPQEzybV0uP1TtzexCS1QOC6tWd4Ke%2FY2jZgKaj2mVjp1Jnh2YecNvz4XKunRsu%2BKoQ34Pf6koDLcweNnKktjY%2BepXwHQ%3D\"}]}","etag":"\"b44f2072efb19546e0ec29081e8a7edc\"","content-length":"761","vary":"Origin"},"url":"https://jsr.io/@std/log/0.224.7/error.ts","time":1785241875}