diff --git a/packages/stryker-api/logging.ts b/packages/stryker-api/logging.ts index 106e0852d0..2a5f0aae51 100644 --- a/packages/stryker-api/logging.ts +++ b/packages/stryker-api/logging.ts @@ -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'; diff --git a/packages/stryker-api/src/logging/LoggerFactory.ts b/packages/stryker-api/src/logging/LoggerFactory.ts deleted file mode 100644 index 54e08c4b9a..0000000000 --- a/packages/stryker-api/src/logging/LoggerFactory.ts +++ /dev/null @@ -1,31 +0,0 @@ -import LoggerFactoryMethod from './LoggerFactoryMethod'; -import Logger from './Logger'; - -const noopLogger: Logger = { - isTraceEnabled(): boolean { return false; }, - isDebugEnabled(): boolean { return false; }, - isInfoEnabled(): boolean { return false; }, - isWarnEnabled(): boolean { return false; }, - isErrorEnabled(): boolean { return false; }, - isFatalEnabled(): boolean { return false; }, - trace(): void { }, - debug(): void { }, - info(): void { }, - warn(): void { }, - error(): void { }, - fatal(): void { } -}; - -let logImplementation: LoggerFactoryMethod = () => noopLogger; - -export default class LoggerFactory { - - public static setLogImplementation(implementation: LoggerFactoryMethod) { - logImplementation = implementation; - } - - public static getLogger: LoggerFactoryMethod = (categoryName?: string) => { - process.emitWarning(`DEPRECATED call to \`getLogger('${categoryName}')\` is deprecated. Stryker plugins should use dependency injection to let loggers be injected`); - return logImplementation(categoryName); - } -} diff --git a/packages/stryker-api/src/logging/getLogger.ts b/packages/stryker-api/src/logging/getLogger.ts deleted file mode 100644 index 2d8bedde89..0000000000 --- a/packages/stryker-api/src/logging/getLogger.ts +++ /dev/null @@ -1,6 +0,0 @@ -import LoggerFactory from './LoggerFactory'; -import LoggerFactoryMethod from './LoggerFactoryMethod'; - -const getLogger: LoggerFactoryMethod = LoggerFactory.getLogger; - -export default getLogger; diff --git a/packages/stryker-javascript-mutator/test/helpers/LogMock.ts b/packages/stryker-javascript-mutator/test/helpers/LogMock.ts deleted file mode 100644 index 0cc86658b6..0000000000 --- a/packages/stryker-javascript-mutator/test/helpers/LogMock.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Logger } from 'stryker-api/logging'; -import { SinonStub } from 'sinon'; - -export default class LogMock implements Mock { - public setLevel: SinonStub = sandbox.stub(); - public isLevelEnabled = sandbox.stub(); - public isTraceEnabled = sandbox.stub(); - public isDebugEnabled = sandbox.stub(); - public isInfoEnabled = sandbox.stub(); - public isWarnEnabled = sandbox.stub(); - public isErrorEnabled = sandbox.stub(); - public isFatalEnabled = sandbox.stub(); - public trace = sandbox.stub(); - public debug = sandbox.stub(); - public info = sandbox.stub(); - public warn = sandbox.stub(); - public error = sandbox.stub(); - public fatal = sandbox.stub(); -} diff --git a/packages/stryker-javascript-mutator/test/helpers/initSinon.ts b/packages/stryker-javascript-mutator/test/helpers/initSinon.ts index d671b5f8cb..3f17ab7b90 100644 --- a/packages/stryker-javascript-mutator/test/helpers/initSinon.ts +++ b/packages/stryker-javascript-mutator/test/helpers/initSinon.ts @@ -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(() => { diff --git a/packages/stryker/src/logging/LogConfigurator.ts b/packages/stryker/src/logging/LogConfigurator.ts index f036164c04..fc17a3a2d7 100644 --- a/packages/stryker/src/logging/LogConfigurator.ts +++ b/packages/stryker/src/logging/LogConfigurator.ts @@ -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'; @@ -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)); } @@ -99,7 +93,6 @@ export default class LogConfigurator { * @returns the context */ public static async configureLoggingServer(consoleLogLevel: LogLevel, fileLogLevel: LogLevel, allowConsoleColors: boolean): Promise { - this.setImplementation(); const loggerPort = await getFreePort(); // Include the appenders for the main Stryker process, as log4js has only one single `configure` method. @@ -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));