cookie and pwa stuff
This commit is contained in:
@@ -46,7 +46,7 @@ class Logger {
|
||||
constructor(context?: string, options: LoggerOptions = {}) {
|
||||
this.context = context;
|
||||
this.options = {
|
||||
enabled: import.meta.env.NODE_ENV !== "production",
|
||||
enabled: true,
|
||||
showTimestamp: true,
|
||||
collapsed: true,
|
||||
colors: true,
|
||||
@@ -75,27 +75,44 @@ class Logger {
|
||||
|
||||
const groupLabel = `${timestamp}${style.label}${context} │ ${label}`;
|
||||
|
||||
const group = this.options.collapsed
|
||||
? console.groupCollapsed
|
||||
: console.group;
|
||||
// In server environment (no window), use simple console.log instead of groups
|
||||
const isServer = typeof window === "undefined";
|
||||
|
||||
if (this.options.colors && typeof window !== "undefined") {
|
||||
group(`%c${groupLabel}`, `color: ${style.color}; font-weight: bold;`);
|
||||
} else {
|
||||
group(groupLabel);
|
||||
}
|
||||
|
||||
if (data !== undefined) {
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
if (rest.length > 0) {
|
||||
for (const item of rest) {
|
||||
console.log(item);
|
||||
if (isServer) {
|
||||
// Server-side: Simple formatted output (no console.group in Node.js)
|
||||
console.log(groupLabel);
|
||||
if (data !== undefined) {
|
||||
console.log(JSON.stringify(data, null, 2));
|
||||
}
|
||||
}
|
||||
if (rest.length > 0) {
|
||||
for (const item of rest) {
|
||||
console.log(JSON.stringify(item, null, 2));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Browser: Use console.group with colors
|
||||
const group = this.options.collapsed
|
||||
? console.groupCollapsed
|
||||
: console.group;
|
||||
|
||||
console.groupEnd();
|
||||
if (this.options.colors) {
|
||||
group(`%c${groupLabel}`, `color: ${style.color}; font-weight: bold;`);
|
||||
} else {
|
||||
group(groupLabel);
|
||||
}
|
||||
|
||||
if (data !== undefined) {
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
if (rest.length > 0) {
|
||||
for (const item of rest) {
|
||||
console.log(item);
|
||||
}
|
||||
}
|
||||
|
||||
console.groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
info(label: string, data?: any, ...rest: any[]): void {
|
||||
|
||||
Reference in New Issue
Block a user