forked from Disciplr-Org/Disciplr-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.ts
More file actions
32 lines (30 loc) · 946 Bytes
/
Copy pathlogger.ts
File metadata and controls
32 lines (30 loc) · 946 Bytes
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
/**
* Thin logger that no-ops non-error levels in production.
* Replace `console.*` calls with these so log level, suppression,
* and future forwarding to an observability service can be controlled
* from one place.
*
* Usage:
* import { logger } from '../utils/logger';
* logger.debug('Loading tokens');
* logger.info('Wallet connected', { address });
* logger.warn('No trustline found');
* logger.error('Connection failed', err);
*/
const isProd = () => import.meta.env.MODE === 'production';
/* eslint-disable no-console */
export const logger = {
debug: (...args: unknown[]): void => {
if (!isProd()) console.debug(...args);
},
info: (...args: unknown[]): void => {
if (!isProd()) console.info(...args);
},
warn: (...args: unknown[]): void => {
if (!isProd()) console.warn(...args);
},
error: (...args: unknown[]): void => {
console.error(...args);
},
};
/* eslint-enable no-console */