2020-09-05 01:31:52 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-02-09 23:44:48 +01:00
|
|
|
import { BrowserContext } from '../browserContext';
|
2021-01-24 17:44:11 +01:00
|
|
|
import { isDebugMode } from '../../utils/utils';
|
2021-01-26 04:01:04 +01:00
|
|
|
import { RecorderSupplement } from './recorderSupplement';
|
2021-02-09 23:44:48 +01:00
|
|
|
import { InstrumentationListener } from '../instrumentation';
|
2021-02-11 06:50:29 +01:00
|
|
|
import { debugLogger } from '../../utils/debugLogger';
|
2020-09-05 01:31:52 +02:00
|
|
|
|
2021-02-09 23:44:48 +01:00
|
|
|
export class InspectorController implements InstrumentationListener {
|
2020-09-05 01:31:52 +02:00
|
|
|
async onContextCreated(context: BrowserContext): Promise<void> {
|
2021-01-25 04:21:19 +01:00
|
|
|
if (isDebugMode()) {
|
2021-02-04 01:01:51 +01:00
|
|
|
RecorderSupplement.getOrCreate(context, {
|
|
|
|
|
language: process.env.PW_CLI_TARGET_LANG || 'javascript',
|
2021-01-26 04:01:04 +01:00
|
|
|
terminal: true,
|
|
|
|
|
});
|
2021-01-25 04:21:19 +01:00
|
|
|
}
|
2020-09-05 01:31:52 +02:00
|
|
|
}
|
2021-02-11 06:50:29 +01:00
|
|
|
|
|
|
|
|
onLog(logName: string, message: string): void {
|
|
|
|
|
debugLogger.log(logName as any, message);
|
|
|
|
|
}
|
2020-09-05 01:31:52 +02:00
|
|
|
}
|