11import { interpolate , Deprecateds } from './messages'
2- import { Logger } from 'bs-logger'
2+ import { Logger , LogContexts } from 'bs-logger'
33
4- // we must use a getter here since the root logger is using ourself
5- let _logger : Logger
6- const logger = {
7- get get ( ) {
8- return (
9- _logger ||
10- ( _logger = require ( './logger' ) . rootLogger . child ( {
11- namespace : 'backports' ,
12- } ) )
13- )
14- } ,
15- }
4+ const context = { [ LogContexts . namespace ] : 'backports' }
165
176export const backportJestConfig = <
187 T extends jest . InitialOptions | jest . ProjectConfig
198> (
20- config : T = { } as any ,
9+ logger : Logger ,
10+ config : T ,
2111) : T => {
22- logger . get . debug ( { config } , 'backporting config' )
12+ logger . debug ( { ... context , config } , 'backporting config' )
2313
24- const { globals = { } } = config as any
14+ const { globals = { } } = ( config || { } ) as any
2515 const { 'ts-jest' : tsJest = { } } = globals as any
2616 const mergeTsJest : any = { }
2717 const warnConfig = ( oldPath : string , newPath : string , note ?: string ) => {
28- logger . get . warn (
18+ logger . warn (
19+ context ,
2920 interpolate (
3021 note ? Deprecateds . ConfigOptionWithNote : Deprecateds . ConfigOption ,
3122 {
@@ -120,7 +111,7 @@ export const backportJestConfig = <
120111 }
121112}
122113
123- export const backportTsJestDebugEnvVar = ( ) => {
114+ export const backportTsJestDebugEnvVar = ( logger : Logger ) => {
124115 if ( 'TS_JEST_DEBUG' in process . env ) {
125116 const shouldLog = ! / ^ \s * (?: 0 | f (?: a l s e ) ? | n o ? | d i s a b l e d ? | o f f | ) \s * $ / i. test (
126117 process . env . TS_JEST_DEBUG || '' ,
@@ -129,8 +120,8 @@ export const backportTsJestDebugEnvVar = () => {
129120 if ( shouldLog ) {
130121 process . env . TS_JEST_LOG = `ts-jest.log,stderr:warn`
131122 }
132- // must be called after because this function is used when the root logger is created
133- logger . get . warn (
123+ logger . warn (
124+ context ,
134125 interpolate ( Deprecateds . EnvVar , {
135126 old : 'TS_JEST_DEBUG' ,
136127 new : 'TS_JEST_LOG' ,
0 commit comments