import { debug, varlockSettings, redactSensitiveConfig } from './chunk-PRASPAE4.js';
import { __name } from './chunk-IBAHCH6O.js';

// src/runtime/patch-console.ts
function patchGlobalConsole() {
  debug("\u26A1\uFE0F PATCHING global console methods");
  if (console.log._varlockPatchedFn) {
    debug("> already patched");
    return;
  }
  if (varlockSettings.redactLogs === false) {
    debug("> disabled by settings");
    return;
  }
  const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === "kWriteToConsole");
  globalThis._varlockOrigWriteToConsoleFn ||= globalThis.console[kWriteToConsoleSymbol];
  globalThis.console[kWriteToConsoleSymbol] = function() {
    globalThis._varlockOrigWriteToConsoleFn.apply(this, [
      arguments[0],
      redactSensitiveConfig(arguments[1]),
      arguments[2]
    ]);
  };
  for (const logMethodName of ["trace", "debug", "info", "log", "info", "warn", "error"]) {
    const originalLogMethod = globalThis.console[logMethodName];
    const patchedFn = /* @__PURE__ */ __name(function() {
      originalLogMethod.apply(this, Array.from(arguments).map(redactSensitiveConfig));
    }, "patchedFn");
    patchedFn._varlockPatchedFn = true;
    globalThis.console[logMethodName] = patchedFn;
  }
}
__name(patchGlobalConsole, "patchGlobalConsole");
function unpatchGlobalConsole() {
  if (!globalThis._varlockOrigWriteToConsoleFn) return;
  const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === "kWriteToConsole");
  globalThis.console[kWriteToConsoleSymbol] = globalThis._varlockOrigWriteToConsoleFn;
  delete globalThis._varlockOrigWriteToConsoleFn;
}
__name(unpatchGlobalConsole, "unpatchGlobalConsole");

export { patchGlobalConsole, unpatchGlobalConsole };
//# sourceMappingURL=chunk-C5R5IRTK.js.map
//# sourceMappingURL=chunk-C5R5IRTK.js.map