-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
import type { BunyanLikeLogger } from './decorator'; | ||
import { Bunyamin } from './decorator'; | ||
import { noopLogger } from './noopLogger'; | ||
import realm from './realm'; | ||
|
||
export * from './noopLogger'; | ||
export * from './traceEventStream'; | ||
export * from './uniteTraceEvents'; | ||
export * from './wrapLogger'; | ||
export * from './is-debug'; | ||
|
||
const threadGroups: any[] = []; | ||
export const bunyamin = new Bunyamin<BunyanLikeLogger>({ logger: noopLogger(), threadGroups }); | ||
export const nobunyamin = new Bunyamin<BunyanLikeLogger>({ | ||
logger: noopLogger(), | ||
threadGroups, | ||
immutable: true, | ||
}); | ||
export const bunyamin = realm.bunyamin; | ||
export const nobunyamin = realm.nobunyamin; | ||
|
||
export default bunyamin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { BunyanLikeLogger } from './decorator'; | ||
import { Bunyamin } from './decorator'; | ||
import { noopLogger } from './noopLogger'; | ||
|
||
type Realm = { | ||
bunyamin: Bunyamin<BunyanLikeLogger>; | ||
nobunyamin: Bunyamin<BunyanLikeLogger>; | ||
}; | ||
|
||
function create() { | ||
const threadGroups: any[] = []; | ||
const bunyamin = new Bunyamin<BunyanLikeLogger>({ logger: noopLogger(), threadGroups }); | ||
const nobunyamin = new Bunyamin<BunyanLikeLogger>({ | ||
logger: noopLogger(), | ||
threadGroups, | ||
immutable: true, | ||
}); | ||
|
||
return { bunyamin, nobunyamin }; | ||
} | ||
|
||
function getCached(): Realm | undefined { | ||
return (globalThis as any).__BUNYAMIN__; | ||
} | ||
|
||
function setCached(realm: Realm) { | ||
(globalThis as any).__BUNYAMIN__ = realm; | ||
return realm; | ||
} | ||
|
||
export default setCached(getCached() ?? create()); |