forked from jsnbuchanan/crowd-funder-for-time-pwa
# Commit Message for SharedArrayBuffer Platform Exclusion
fix: eliminate SharedArrayBuffer checks on non-web platforms * Add platform guard in AbsurdSqlDatabaseService to only initialize on web * Change singleton pattern from eager to lazy instantiation * Update worker import to use lazy singleton pattern * Prevents absurd-sql initialization on Electron/Capacitor platforms * Reduces console noise and memory footprint on desktop/mobile * Maintains full web platform functionality and performance Resolves SharedArrayBuffer-related console output on Electron platform while preserving all web features and maintaining clean architecture.
This commit is contained in:
@@ -19,22 +19,35 @@ export function safeStringify(obj: unknown) {
|
||||
});
|
||||
}
|
||||
|
||||
// Determine if we should suppress verbose logging (for Electron)
|
||||
const isElectron = process.env.VITE_PLATFORM === "electron";
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
|
||||
export const logger = {
|
||||
debug: (message: string, ...args: unknown[]) => {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
// Debug logs are very verbose - only show in development mode for web
|
||||
if (!isProduction && !isElectron) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.debug(message, ...args);
|
||||
// const argsString = args.length > 0 ? " - " + safeStringify(args) : "";
|
||||
// logToDb(message + argsString);
|
||||
}
|
||||
// Don't log debug messages to database to reduce noise
|
||||
},
|
||||
log: (message: string, ...args: unknown[]) => {
|
||||
// Regular logs - show in development or for capacitor, but quiet for Electron
|
||||
if (
|
||||
process.env.NODE_ENV !== "production" ||
|
||||
(!isProduction && !isElectron) ||
|
||||
process.env.VITE_PLATFORM === "capacitor"
|
||||
) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message, ...args);
|
||||
}
|
||||
|
||||
// Only log to database for important messages (not routine operations)
|
||||
if (
|
||||
!message.includes("[CapacitorPlatformService]") &&
|
||||
!message.includes("[CapacitorMigration]") &&
|
||||
!message.includes("[DB-Integrity]")
|
||||
) {
|
||||
const argsString = args.length > 0 ? " - " + safeStringify(args) : "";
|
||||
logToDb(message + argsString);
|
||||
}
|
||||
@@ -52,10 +65,17 @@ export const logger = {
|
||||
}
|
||||
},
|
||||
warn: (message: string, ...args: unknown[]) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(message, ...args);
|
||||
const argsString = args.length > 0 ? " - " + safeStringify(args) : "";
|
||||
logToDb(message + argsString);
|
||||
// Always show warnings, but for Electron, suppress routine database warnings
|
||||
if (!isElectron || !message.includes("[CapacitorPlatformService]")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(message, ...args);
|
||||
}
|
||||
|
||||
// Log warnings to database, but filter out routine operations
|
||||
if (!message.includes("[CapacitorPlatformService]")) {
|
||||
const argsString = args.length > 0 ? " - " + safeStringify(args) : "";
|
||||
logToDb(message + argsString);
|
||||
}
|
||||
},
|
||||
error: (message: string, ...args: unknown[]) => {
|
||||
// Errors will always be logged
|
||||
|
||||
Reference in New Issue
Block a user