How to use the @stryker-mutator/api/plugin.commonTokens.getLogger function in @stryker-mutator/api

To help you get started, we’ve selected a few @stryker-mutator/api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stryker-mutator / stryker / packages / core / src / Stryker.ts View on Github external
constructor(cliOptions: Partial) {
    LogConfigurator.configureMainProcess(cliOptions.logLevel, cliOptions.fileLogLevel, cliOptions.allowConsoleColors);
    this.injector = buildMainInjector(cliOptions);
    this.log = this.injector.resolve(commonTokens.getLogger)(Stryker.name);
    // Log level may have changed
    LogConfigurator.configureMainProcess(this.options.logLevel, this.options.fileLogLevel, this.options.allowConsoleColors);
  }
github stryker-mutator / stryker / packages / test-helpers / src / TestInjector.ts View on Github external
private readonly provideLogger = (): Logger => {
    return this.logger;
  };
  private readonly provideOptions = () => {
    return this.options;
  };
  private readonly provideMutatorDescriptor = () => {
    return this.mutatorDescriptor;
  };

  public pluginResolver: sinon.SinonStubbedInstance;
  public options: StrykerOptions;
  public mutatorDescriptor: MutatorDescriptor;
  public logger: sinon.SinonStubbedInstance;
  public injector: Injector = rootInjector
    .provideValue(commonTokens.getLogger, this.provideLogger)
    .provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
    .provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
    .provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient)
    .provideFactory(commonTokens.mutatorDescriptor, this.provideMutatorDescriptor, Scope.Transient);

  public reset() {
    this.mutatorDescriptor = factory.mutatorDescriptor();
    this.options = factory.strykerOptions();
    this.logger = factory.logger();
    this.pluginResolver = {
      resolve: sinon.stub(),
      resolveAll: sinon.stub()
    };
  }
}
github stryker-mutator / stryker / packages / karma-runner / src / KarmaTestRunner.ts View on Github external
import TestHooksMiddleware from './TestHooksMiddleware';

export interface ConfigOptions extends karma.ConfigOptions {
  detached?: boolean;
}

export default class KarmaTestRunner implements TestRunner {
  private currentTestResults: TestResult[];
  private currentErrorMessages: string[];
  private currentCoverageReport?: CoverageCollection | CoveragePerTestResult;
  private currentRunStatus: RunStatus;
  private readonly testHooksMiddleware = TestHooksMiddleware.instance;
  private readonly starter: ProjectStarter;
  public port: undefined | number;

  public static inject = tokens(commonTokens.logger, commonTokens.getLogger, commonTokens.options);
  constructor(private readonly log: Logger, getLogger: LoggerFactoryMethod, options: StrykerOptions) {
    const setup = this.loadSetup(options);
    this.starter = new ProjectStarter(getLogger, setup);
    this.setGlobals(setup, getLogger);
    this.cleanRun();
    this.listenToServerStart();
    this.listenToRunComplete();
    this.listenToSpecComplete();
    this.listenToCoverage();
    this.listenToError();
  }

  public init(): Promise {
    return new Promise((res, rej) => {
      StrykerReporter.instance.once('browsers_ready', res);
      this.starter
github stryker-mutator / stryker / packages / core / src / di / factoryMethods.ts View on Github external
pluginLoader.load();
  return pluginLoader;
}
pluginResolverFactory.inject = tokens(commonTokens.injector);

export function testFrameworkFactory(
  injector: Injector }>
) {
  return injector.injectClass(TestFrameworkOrchestrator).determineTestFramework();
}
testFrameworkFactory.inject = tokens(commonTokens.injector);

export function loggerFactory(getLogger: LoggerFactoryMethod, target: Function | undefined) {
  return getLogger(target ? target.name : 'UNKNOWN');
}
loggerFactory.inject = tokens(commonTokens.getLogger, commonTokens.target);

export function optionsFactory(config: Config, configEditorApplier: ConfigEditorApplier): StrykerOptions {
  configEditorApplier.edit(config);
  return freezeRecursively(config);
}
optionsFactory.inject = tokens<[typeof coreTokens.configReadFromConfigFile, typeof coreTokens.configEditorApplier]>(
  coreTokens.configReadFromConfigFile,
  coreTokens.configEditorApplier
);

export function mutatorDescriptorFactory(options: StrykerOptions): MutatorDescriptor {
  const defaults: MutatorDescriptor = {
    plugins: null,
    name: 'javascript',
    excludedMutations: []
  };
github stryker-mutator / stryker / packages / core / src / initializer / index.ts View on Github external
export function initializerFactory(): StrykerInitializer {
  return rootInjector
    .provideValue(commonTokens.getLogger, getLogger)
    .provideFactory(commonTokens.logger, loggerFactory)
    .provideValue(initializerTokens.out, console.log)
    .provideValue(initializerTokens.strykerPresets, strykerPresets)
    .provideValue(initializerTokens.restClientNpmSearch, new RestClient('npmSearch', BASE_NPM_SEARCH))
    .provideValue(initializerTokens.restClientNpm, new RestClient('npm', BASE_NPM_PACKAGE))
    .provideClass(initializerTokens.npmClient, NpmClient)
    .provideClass(initializerTokens.configWriter, StrykerConfigWriter)
    .provideClass(initializerTokens.gitignoreWriter, GitignoreWriter)
    .provideClass(initializerTokens.inquirer, StrykerInquirer)
    .injectClass(StrykerInitializer);
}
github stryker-mutator / stryker / packages / core / src / di / buildMainInjector.ts View on Github external
export function buildMainInjector(cliOptions: Partial): Injector {
  return rootInjector
    .provideValue(commonTokens.getLogger, getLogger)
    .provideFactory(commonTokens.logger, loggerFactory, Scope.Transient)
    .provideValue(coreTokens.cliOptions, cliOptions)
    .provideClass(coreTokens.configReader, ConfigReader)
    .provideFactory(coreTokens.configReadFromConfigFile, readConfig)
    .provideFactory(coreTokens.pluginDescriptors, pluginDescriptorsFactory)
    .provideFactory(commonTokens.pluginResolver, pluginResolverFactory)
    .provideFactory(coreTokens.pluginCreatorConfigEditor, PluginCreator.createFactory(PluginKind.ConfigEditor))
    .provideClass(coreTokens.configEditorApplier, ConfigEditorApplier)
    .provideFactory(commonTokens.options, optionsFactory)
    .provideFactory(commonTokens.mutatorDescriptor, mutatorDescriptorFactory)
    .provideFactory(coreTokens.pluginCreatorReporter, PluginCreator.createFactory(PluginKind.Reporter))
    .provideFactory(coreTokens.pluginCreatorTestFramework, PluginCreator.createFactory(PluginKind.TestFramework))
    .provideFactory(coreTokens.pluginCreatorMutator, PluginCreator.createFactory(PluginKind.Mutator))
    .provideClass(coreTokens.reporter, BroadcastReporter)
    .provideFactory(coreTokens.testFramework, testFrameworkFactory)
    .provideClass(coreTokens.temporaryDirectory, TemporaryDirectory)
github stryker-mutator / stryker / packages / core / src / di / buildChildProcessInjector.ts View on Github external
export function buildChildProcessInjector(options: StrykerOptions): Injector {
  return rootInjector
    .provideValue(commonTokens.options, options)
    .provideValue(commonTokens.getLogger, getLogger)
    .provideFactory(commonTokens.logger, loggerFactory, Scope.Transient)
    .provideFactory(coreTokens.pluginDescriptors, pluginDescriptorsFactory)
    .provideFactory(commonTokens.pluginResolver, pluginResolverFactory)
    .provideFactory(commonTokens.mutatorDescriptor, mutatorDescriptorFactory);
}