fix issues
This commit is contained in:
@@ -35,14 +35,29 @@ export class ConsoleLogger implements Logger {
|
||||
const emoji = this.EMOJIS[level];
|
||||
const prefix = this.PREFIXES[level];
|
||||
|
||||
console.groupCollapsed(`%c${emoji} [${source.toUpperCase()}] ${prefix}: ${message}`, `color: ${color}; font-weight: bold;`);
|
||||
// Edge runtime doesn't support console.groupCollapsed/groupEnd
|
||||
// Fallback to simple logging for compatibility
|
||||
const supportsGrouping = typeof console.groupCollapsed === 'function' && typeof console.groupEnd === 'function';
|
||||
|
||||
if (supportsGrouping) {
|
||||
// Safe to call - we've verified both functions exist
|
||||
(console as any).groupCollapsed(`%c${emoji} [${source.toUpperCase()}] ${prefix}: ${message}`, `color: ${color}; font-weight: bold;`);
|
||||
} else {
|
||||
// Simple format for edge runtime
|
||||
console.log(`${emoji} [${source.toUpperCase()}] ${prefix}: ${message}`);
|
||||
}
|
||||
|
||||
console.log(`%cTimestamp:`, 'color: #666; font-weight: bold;', new Date().toISOString());
|
||||
console.log(`%cSource:`, 'color: #666; font-weight: bold;', source);
|
||||
|
||||
if (context) {
|
||||
console.log(`%cContext:`, 'color: #666; font-weight: bold;');
|
||||
console.dir(context, { depth: 3, colors: true });
|
||||
// console.dir may not be available in edge runtime
|
||||
if (typeof console.dir === 'function') {
|
||||
console.dir(context, { depth: 3, colors: true });
|
||||
} else {
|
||||
console.log(JSON.stringify(context, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -56,7 +71,10 @@ export class ConsoleLogger implements Logger {
|
||||
}
|
||||
}
|
||||
|
||||
console.groupEnd();
|
||||
if (supportsGrouping) {
|
||||
// Safe to call - we've verified the function exists
|
||||
(console as any).groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
debug(message: string, context?: unknown): void {
|
||||
|
||||
Reference in New Issue
Block a user