Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit ec1c202

Browse files
authored
Merge pull request #41 from Financial-Times/kiya/update-prod-test
Update the logic that tests if the logger is used in production env or not
2 parents 1214275 + d4c42b7 commit ec1c202

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Pino adds the following properties to logs by default:
6969

7070
## Configuration
7171

72-
- `NODE_ENV` - pretty printing is enabled when `NODE_ENV !== 'production'`.
72+
- `NODE_ENV` - pretty printing is enabled when value of `NODE_ENV` is not same as `p`, `prod` or `production`.
7373
- `CONSOLE_LOG_LEVEL` - determines the level to log at (pinto `level` option). Defaults to `info`.
7474
- `SYSTEM_CODE` - adds the `systemCode` property to every log.
7575
- `ENVIRONMENT|STAGE` - adds the `environment` property to every log. `STAGE` is used as a fallback due to it's default definition in the [serverless](https://serverless.com) framework.

lib/logger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pino from 'pino';
22

3-
const isProduction = () => process.env.NODE_ENV === 'production';
3+
const prodTerms = ['production', 'prod', 'p'];
4+
const isProduction = () => prodTerms.includes(process.env.NODE_ENV);
45
const isLambda = () =>
56
!!(
67
(process.env.LAMBDA_TASK_ROOT && process.env.AWS_EXECUTION_ENV) ||

0 commit comments

Comments
 (0)