mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 19:52:53 +00:00
fix: removing transformations in production
This commit is contained in:
@@ -239,20 +239,27 @@ export class LoggerSpec {
|
||||
|
||||
@test
|
||||
'is compatible with log aggregation in productive environment'() {
|
||||
const nodeEnv = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = 'production';
|
||||
process.env.ALLOW_NO_TRANSPORT = 'true';
|
||||
|
||||
Logger.setTransformations([new AddLogLevel(), new Colorize()]);
|
||||
|
||||
const spy = LoggerSpec.sandbox.on(console, 'log', () => {
|
||||
let spy = LoggerSpec.sandbox.on(console, 'log', () => {
|
||||
// noop
|
||||
});
|
||||
|
||||
Logger.log('Foo\nbar');
|
||||
|
||||
expect(spy).to.have.been.called.once;
|
||||
expect(spy.__spy.calls[0][0]).to.equal('[LOG] Foo bar');
|
||||
expect(spy.__spy.calls[0][0]).to.equal('\u001B[37m[LOG] Foo\u001B[39m\n\u001B[37mbar\u001B[39m');
|
||||
|
||||
const nodeEnv = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = 'production';
|
||||
process.env.ALLOW_NO_TRANSPORT = 'true';
|
||||
|
||||
Logger.setTransformations([new AddLogLevel(), new Colorize()]);
|
||||
|
||||
Logger.log('Foo\nbar');
|
||||
|
||||
expect(spy).to.have.been.called.twice;
|
||||
expect(spy.__spy.calls[1][0]).to.equal('[LOG] Foo bar');
|
||||
|
||||
process.env.NODE_ENV = nodeEnv;
|
||||
delete process.env.ALLOW_NO_TRANSPORT;
|
||||
|
||||
Reference in New Issue
Block a user