mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 07:51:13 -05:00
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
/**
|
|
* Logger Utility
|
|
*
|
|
* Provides conditional logging based on environment.
|
|
* Prevents console noise in production builds.
|
|
*/
|
|
|
|
const isDev = import.meta.env.DEV;
|
|
|
|
type LogContext = Record<string, unknown>;
|
|
|
|
export const logger = {
|
|
log: (...args: unknown[]): void => {
|
|
if (isDev) console.log(...args);
|
|
},
|
|
error: (message: string, context?: LogContext): void => {
|
|
console.error(message, context); // Always log errors
|
|
},
|
|
warn: (...args: unknown[]): void => {
|
|
if (isDev) console.warn(...args);
|
|
},
|
|
info: (...args: unknown[]): void => {
|
|
if (isDev) console.info(...args);
|
|
},
|
|
debug: (...args: unknown[]): void => {
|
|
if (isDev) console.debug(...args);
|
|
},
|
|
// Performance monitoring
|
|
performance: (component: string, duration: number): void => {
|
|
if (isDev) {
|
|
console.log(`⚡ ${component} rendered in ${duration}ms`, {
|
|
component,
|
|
duration,
|
|
category: 'performance',
|
|
});
|
|
}
|
|
},
|
|
// Moderation action tracking
|
|
moderationAction: (action: string, itemId: string, duration: number): void => {
|
|
if (isDev) {
|
|
console.log(`🎯 Moderation action: ${action}`, {
|
|
action,
|
|
itemId,
|
|
duration,
|
|
category: 'moderation',
|
|
});
|
|
}
|
|
}
|
|
};
|