Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 33x 3x 1x 2x 3x 1x 2x 9x 1x 8x 33x 7x 26x | // src/services/logger.client.ts
/**
* A simple, client-side logger service that wraps the console.
* This version is guaranteed to be safe for browser environments as it
* does not reference any Node.js-specific globals like `process`.
*/
// Export the logger object for use throughout the client-side application.
/**
* A simple, client-side logger that mimics the pino API for structured logging.
* It supports signatures like `logger.info('message')` and `logger.info({ data }, 'message')`.
*/
export const logger = {
info: (objOrMsg: Record<string, unknown> | string, ...args: unknown[]) => {
if (typeof objOrMsg === 'string') {
console.log(`[INFO] ${objOrMsg}`, ...args);
} else {
console.log(`[INFO] ${args[0] || ''}`, objOrMsg, ...args.slice(1));
}
},
warn: (objOrMsg: Record<string, unknown> | string, ...args: unknown[]) => {
if (typeof objOrMsg === 'string') {
console.warn(`[WARN] ${objOrMsg}`, ...args);
} else {
console.warn(`[WARN] ${args[0] || ''}`, objOrMsg, ...args.slice(1));
}
},
error: (objOrMsg: Record<string, unknown> | string, ...args: unknown[]) => {
if (typeof objOrMsg === 'string') {
console.error(`[ERROR] ${objOrMsg}`, ...args);
} else {
console.error(`[ERROR] ${args[0] || ''}`, objOrMsg, ...args.slice(1));
}
},
debug: (objOrMsg: Record<string, unknown> | string, ...args: unknown[]) => {
if (typeof objOrMsg === 'string') {
console.debug(`[DEBUG] ${objOrMsg}`, ...args);
} else {
console.debug(`[DEBUG] ${args[0] || ''}`, objOrMsg, ...args.slice(1));
}
},
};
|