1 | import { createLogger } from './factories/createLogger';
|
2 | import { createRoarrInitialGlobalStateBrowser } from './factories/createRoarrInitialGlobalStateBrowser';
|
3 | import { type MessageSerializer, type RoarrGlobalState } from './types';
|
4 | import { stringify } from './utilities/stringify';
|
5 |
|
6 | const ROARR = createRoarrInitialGlobalStateBrowser(
|
7 | (globalThis.ROARR as RoarrGlobalState) || {},
|
8 | );
|
9 |
|
10 | globalThis.ROARR = ROARR;
|
11 |
|
12 | const serializeMessage: MessageSerializer = (message) => {
|
13 | return stringify(message);
|
14 | };
|
15 |
|
16 | const Roarr = createLogger((message) => {
|
17 | if (ROARR.write) {
|
18 |
|
19 |
|
20 | ROARR.write((ROARR.serializeMessage ?? serializeMessage)(message));
|
21 | }
|
22 | });
|
23 |
|
24 | export type {
|
25 | Logger,
|
26 | LogLevelName,
|
27 | Message,
|
28 | MessageContext,
|
29 | MessageEventHandler,
|
30 | MessageSerializer,
|
31 | RoarrGlobalState,
|
32 | TransformMessageFunction,
|
33 | } from './types';
|
34 |
|
35 | export { ROARR, Roarr };
|
36 |
|
37 | export { logLevels } from './constants';
|
38 | export { getLogLevelName } from './getLogLevelName';
|