-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(async-ssr-manager): use Logger Feature Service instead of console (
#415) The integrator can now provide the Logger Feature Service, which the Async SSR Manager then uses for logging. The Async SSR Manager declares the Logger Feature Service as an optional dependency, and uses console as a fallback logger, when the Logger Feature Service is not provided.
- Loading branch information
1 parent
a363757
commit e0f0605
Showing
6 changed files
with
99 additions
and
14 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
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
12 changes: 12 additions & 0 deletions
12
packages/async-ssr-manager/src/__tests__/stubbed-logger.ts
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,12 @@ | ||
// tslint:disable:no-implicit-dependencies | ||
|
||
import {Logger} from '@feature-hub/logger'; | ||
import {Stub} from 'jest-stub-methods'; | ||
|
||
export const stubbedLogger: Stub<Logger> = { | ||
trace: jest.fn(), | ||
debug: jest.fn(), | ||
info: jest.fn(), | ||
warn: jest.fn(), | ||
error: jest.fn() | ||
}; |
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
14 changes: 14 additions & 0 deletions
14
packages/async-ssr-manager/src/internal/async-ssr-manager-context.ts
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,14 @@ | ||
import {Logger} from '@feature-hub/logger'; | ||
import {AsyncSsrManagerDependencies} from '..'; | ||
|
||
export interface AsyncSsrManagerContext { | ||
readonly logger: Logger; | ||
} | ||
|
||
export function createAsyncSsrManagerContext( | ||
featureServices: AsyncSsrManagerDependencies | ||
): AsyncSsrManagerContext { | ||
const logger = featureServices['s2:logger'] || console; | ||
|
||
return {logger}; | ||
} |
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