refactor console imports, added config update event

This commit is contained in:
dswbx
2025-07-02 14:02:50 +02:00
parent d41fd5541f
commit 70737c04cd
48 changed files with 100 additions and 63 deletions

View File

@@ -1,6 +1,6 @@
import { type Event, type EventClass, InvalidEventReturn } from "./Event";
import { EventListener, type ListenerHandler, type ListenerMode } from "./EventListener";
import { $console } from "core";
import { $console } from "core/utils";
export type RegisterListenerConfig =
| ListenerMode

View File

@@ -38,7 +38,6 @@ export {
} from "./object/schema";
export * from "./drivers";
export * from "./console";
export * from "./events";
// compatibility

View File

@@ -2,7 +2,7 @@ import { extension, guess, isMimeType } from "media/storage/mime-types-tiny";
import { randomString } from "core/utils/strings";
import type { Context } from "hono";
import { invariant } from "core/utils/runtime";
import { $console } from "../console";
import { $console } from "./console";
export function getContentName(request: Request): string | undefined;
export function getContentName(contentDisposition: string): string | undefined;

View File

@@ -1,3 +1,4 @@
export * from "./console";
export * from "./browser";
export * from "./objects";
export * from "./strings";

View File

@@ -1,4 +1,4 @@
import { $console } from "core";
import { $console } from "./console";
type ConsoleSeverity = "log" | "warn" | "error";
const _oldConsoles = {
@@ -36,14 +36,14 @@ export function disableConsoleLog(severities: ConsoleSeverity[] = ["log", "warn"
severities.forEach((severity) => {
console[severity] = () => null;
});
$console.setLevel("critical");
$console?.setLevel("critical");
}
export function enableConsoleLog() {
Object.entries(_oldConsoles).forEach(([severity, fn]) => {
console[severity as ConsoleSeverity] = fn;
});
$console.resetLevel();
$console?.resetLevel();
}
export function formatMemoryUsage() {