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

19 lines
421 B
TypeScript
Raw Normal View History

2020-03-29 13:43:52 +00:00
import { ConsoleLogger, Logger, NullLogger } from 'noicejs';
import { isDebug } from './utils/Env';
2020-03-29 13:43:52 +00:00
export function getTestLogger(verbose = false): Logger {
if (verbose || isDebug()) {
return ConsoleLogger.global;
2020-03-29 13:43:52 +00:00
} else {
return NullLogger.global;
2020-03-29 13:43:52 +00:00
}
}
export function spyLogger(spies: Partial<Logger>): Logger {
const logger = {
...spies,
child: () => logger,
} as Logger;
return logger;
}