Skip to content

Commit

Permalink
feat(getLogger): remove getLogger and LoggerFactory from the API (#1385)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removed `getLogger` and `LoggerFactory` from the API. Please use dependency injection to inject a logger. See https://github.com/stryker-mutator/stryker-handbook/blob/master/stryker/api/plugins.md#plugins for more detail
  • Loading branch information
simondel authored and nicojs committed Feb 12, 2019
1 parent 9c65aa2 commit cb14e67
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 70 deletions.
2 changes: 0 additions & 2 deletions packages/stryker-api/logging.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export { default as LoggerFactory } from './src/logging/LoggerFactory';
export { default as Logger } from './src/logging/Logger';
export { default as LoggerFactoryMethod } from './src/logging/LoggerFactoryMethod';
export { default as getLogger } from './src/logging/getLogger';
31 changes: 0 additions & 31 deletions packages/stryker-api/src/logging/LoggerFactory.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/stryker-api/src/logging/getLogger.ts

This file was deleted.

19 changes: 0 additions & 19 deletions packages/stryker-javascript-mutator/test/helpers/LogMock.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/stryker-javascript-mutator/test/helpers/initSinon.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import * as sinon from 'sinon';
import * as logging from 'stryker-api/logging';
import LogMock from './LogMock';

beforeEach(() => {
global.sandbox = sinon.createSandbox();
global.logMock = new LogMock();
global.sandbox.stub(logging, 'getLogger').returns(global.logMock);
});

afterEach(() => {
Expand Down
8 changes: 0 additions & 8 deletions packages/stryker/src/logging/LogConfigurator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as log4js from 'log4js';
import { LoggerFactory } from 'stryker-api/logging';
import { LogLevel } from 'stryker-api/core';
import { minLevel } from './logUtils';
import LoggingClientContext from './LoggingClientContext';
Expand Down Expand Up @@ -74,17 +73,12 @@ export default class LogConfigurator {
};
}

private static setImplementation(): void {
LoggerFactory.setLogImplementation(log4js.getLogger);
}

/**
* Configure logging for the master process. Either call this method or `configureChildProcess` before any `getLogger` calls.
* @param consoleLogLevel The log level to configure for the console
* @param fileLogLevel The log level to configure for the "stryker.log" file
*/
public static configureMainProcess(consoleLogLevel: LogLevel = LogLevel.Information, fileLogLevel: LogLevel = LogLevel.Off, allowConsoleColors: boolean = true) {
this.setImplementation();
const appenders = this.createMainProcessAppenders(consoleLogLevel, fileLogLevel, allowConsoleColors);
log4js.configure(this.createLog4jsConfig(minLevel(consoleLogLevel, fileLogLevel), appenders));
}
Expand All @@ -99,7 +93,6 @@ export default class LogConfigurator {
* @returns the context
*/
public static async configureLoggingServer(consoleLogLevel: LogLevel, fileLogLevel: LogLevel, allowConsoleColors: boolean): Promise<LoggingClientContext> {
this.setImplementation();
const loggerPort = await getFreePort();

// Include the appenders for the main Stryker process, as log4js has only one single `configure` method.
Expand Down Expand Up @@ -127,7 +120,6 @@ export default class LogConfigurator {
* @param context the logging client context used to configure the logging client
*/
public static configureChildProcess(context: LoggingClientContext) {
this.setImplementation();
const clientAppender: log4js.MultiprocessAppender = { type: 'multiprocess', mode: 'worker', loggerPort: context.port };
const appenders: AppendersConfiguration = { [AppenderName.All]: clientAppender };
log4js.configure(this.createLog4jsConfig(context.level, appenders));
Expand Down

0 comments on commit cb14e67

Please sign in to comment.