All files / app/common/error createErrorLogger.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2380x   80x 80x   80x       52x 1x           51x 51x          
import ConsoleErrorLogger from './ConsoleErrorLogger';
import ErrorLogger, { ErrorLoggerOptions, ErrorLoggerServiceConfig } from './ErrorLogger';
import NoopErrorLogger from './NoopErrorLogger';
import SentryErrorLogger from './SentryErrorLogger';
 
export default function createErrorLogger(
    serviceConfig?: ErrorLoggerServiceConfig,
    options?: ErrorLoggerOptions
): ErrorLogger {
    if (serviceConfig && serviceConfig.sentry) {
        return new SentryErrorLogger(
            serviceConfig.sentry,
            { ...options, consoleLogger: new ConsoleErrorLogger(options) }
        );
    }
 
    Eif (process.env.NODE_ENV === 'test') {
        return new NoopErrorLogger();
    }
 
    return new ConsoleErrorLogger(options);
}