Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -1,9 +1,26 @@
|
||||
import { createChildLogger, defaultLogger, type HiveGridLogger } from "@hivegrid/logger";
|
||||
import { getWebServiceName, type WebBuildSurface } from "../../build-surface";
|
||||
|
||||
export interface WebLogIdentity {
|
||||
service: "hivegrid-web" | "hivegrid-admin" | "hivegrid-portal";
|
||||
surface: WebBuildSurface;
|
||||
}
|
||||
|
||||
export function requireWebLogIdentity(env: Readonly<{ NODE_ENV?: string; VITEST?: string; WEB_RUNTIME_SURFACE?: string }> = process.env): WebLogIdentity {
|
||||
const surface = env.WEB_RUNTIME_SURFACE;
|
||||
if (surface === "core" || surface === "admin" || surface === "portal") {
|
||||
return { service: getWebServiceName(surface), surface };
|
||||
}
|
||||
if (surface === undefined && (env.NODE_ENV === "test" || env.VITEST === "true")) {
|
||||
return { service: getWebServiceName("core"), surface: "core" };
|
||||
}
|
||||
throw new Error("WEB_RUNTIME_SURFACE must be explicitly set to core, admin, or portal before web logger initialization");
|
||||
}
|
||||
|
||||
// Top-level logger for the React Router web runtime. Use webLogger directly
|
||||
// for one-off server-side messages or .child({ scope: "..." }) for module-scoped
|
||||
// loggers that auto-prefix every record.
|
||||
export const webLogger: HiveGridLogger = defaultLogger.child({ service: "web" });
|
||||
export const webLogger: HiveGridLogger = defaultLogger.child(requireWebLogIdentity());
|
||||
|
||||
export function createScopedLogger(scope: string, bindings: Record<string, unknown> = {}): HiveGridLogger {
|
||||
return createChildLogger(webLogger, { scope, ...bindings });
|
||||
|
||||
Reference in new issue
Block a user