(level: ILogLevel, payload: ILogEvent)
| 32 | } |
| 33 | |
| 34 | export function emit(level: ILogLevel, payload: ILogEvent): void { |
| 35 | const maskedRaw = mask(payload); |
| 36 | const masked: Record<string, unknown> = isRecord(maskedRaw) ? maskedRaw : {}; |
| 37 | const entry = { |
| 38 | level, |
| 39 | timestamp: now(), |
| 40 | app: env.VITE_APP_NAME, |
| 41 | ...masked |
| 42 | }; |
| 43 | |
| 44 | if (env.DEV) { |
| 45 | const fn = level === "error" ? console.error : console.log; |
| 46 | |
| 47 | fn(entry); |
| 48 | |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | /* |
| 53 | * Production is breadcrumb-only: entries ride along with Sentry events |
| 54 | * instead of landing in the browser console, where they would expose the |
| 55 | * app's event stream to anyone with devtools open. |
| 56 | */ |
| 57 | Sentry.addBreadcrumb({ |
| 58 | level: level === "warn" ? "warning" : level, |
| 59 | category: typeof masked.event === "string" ? masked.event : "log", |
| 60 | data: masked |
| 61 | }); |
| 62 | } |
no test coverage detected