Skip to content

Commit

Permalink
chore: remove logging when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
letehaha committed Sep 26, 2024
1 parent 4357c03 commit b05226b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 28 deletions.
6 changes: 6 additions & 0 deletions src/js/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import winston, { format, transports } from 'winston';

const createWinstonLogger = () => {
if (process.env.NODE_ENV === 'test') {
return winston.createLogger({
silent: true,
});
}

return winston.createLogger({
level: 'info',
format: format.combine(
Expand Down
19 changes: 9 additions & 10 deletions src/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ export const redisClient = createClient({
},
});

console.time('connect-to-redis');
redisClient
.connect()
.then(() => {
console.log('App connected to Redis! Took: ');
console.timeEnd('connect-to-redis');
})
.catch((err) => {
console.error('Cannot connect to Redis!', err);
});
// console.time('connect-to-redis');
redisClient.connect();
// .then(() => {
// console.log('App connected to Redis! Took: ');
// console.timeEnd('connect-to-redis');
// })
// .catch((err) => {
// console.error('Cannot connect to Redis!', err);
// });

redisClient.on('error', (error: Error) => {
logger.error({ message: 'Redis Client Error', error });
Expand Down
4 changes: 1 addition & 3 deletions src/services/calculate-ref-amount.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ async function calculateRefAmountImpl(params: Params): Promise<number> {

return isNegative ? refAmount * -1 : refAmount;
} catch (e) {
if (process.env.NODE_ENV !== 'test') {
logger.error(e);
}
logger.error(e);
throw e;
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/services/transactions/create-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ export const createTransaction = withTransaction(

return transactions;
} catch (e) {
if (process.env.NODE_ENV !== 'test') {
logger.error(e);
}
logger.error(e);
throw e;
}
},
Expand Down
4 changes: 1 addition & 3 deletions src/services/transactions/delete-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ export const deleteTransaction = withTransaction(async (params: Params): Promise
),
);
} catch (e) {
if (process.env.NODE_ENV !== 'test') {
logger.error(e);
}
logger.error(e);
throw e;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export const linkTransactions = withTransaction(

return result;
} catch (err) {
if (process.env.NODE_ENV !== 'test') {
logger.error(err);
}
logger.error(err);
throw err;
}
},
Expand Down
4 changes: 1 addition & 3 deletions src/services/tx-refunds/create-single-refund.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ export const createSingleRefund = withTransaction(

return refundTransaction;
} catch (e) {
if (process.env.NODE_ENV !== 'test') {
logger.error(e);
}
logger.error(e);
throw e;
}
},
Expand Down
4 changes: 1 addition & 3 deletions src/services/tx-refunds/remove-refund-link.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export const removeRefundLink = withTransaction(
`Refund link between transactions ${originalTxId} and ${refundTxId} removed successfully`,
);
} catch (e) {
if (process.env.NODE_ENV !== 'test') {
logger.error('Error removing refund link:', e);
}
logger.error('Error removing refund link:', e);
throw e;
}
},
Expand Down

0 comments on commit b05226b

Please sign in to comment.