1
0
Fork 0
js-utils/src/Logger.ts

20 lines
432 B
TypeScript
Raw Normal View History

2020-03-29 13:43:52 +00:00
import { ConsoleLogger, Logger, NullLogger } from 'noicejs';
const ENV_DEBUG = 'DEBUG';
export function getTestLogger(verbose = false): Logger {
if (verbose || process.env[ENV_DEBUG] === 'TRUE') {
return new ConsoleLogger();
} else {
return new NullLogger();
}
}
export function spyLogger(spies: Partial<Logger>): Logger {
const logger = {
...spies,
child: () => logger,
} as Logger;
return logger;
}