Skip to content

Commit 132aade

Browse files
committed
Make timestamp prefix in logs configurable
1 parent 14a9e9c commit 132aade

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

config/default.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"host": "smtp-relay.sendinblue.com",
4949
"username": "[email protected]"
5050
},
51-
"sendMailOnError": false
51+
"sendMailOnError": false,
52+
"timestampPrefix": true
5253
},
5354
"notifier": {
5455
"sendInBlue": {

scripts/dataset/logger/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import config from 'config';
12
import winston from 'winston';
23

34
import logger from '../../../src/logger/index.js';
@@ -10,7 +11,7 @@ logger.format = combine(
1011
printf(({ level, message, counter, hash, timestamp }) => {
1112
const prefix = counter && hash ? `${counter.toString().padEnd(6)} ${hash.padEnd(40)}` : '';
1213

13-
const timestampPrefix = process.env.NODE_ENV !== 'production' ? `${timestamp} ` : '';
14+
const timestampPrefix = config.get('@opentermsarchive/engine.logger.timestampPrefix') ? `${timestamp} ` : '';
1415

1516
return `${timestampPrefix}${level.padEnd(15)} ${prefix.padEnd(50)} ${message}`;
1617
}),

src/collection-api/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const logger = winston.createLogger({
3232
colorize(),
3333
timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
3434
printf(({ level, message, timestamp }) => {
35-
const timestampPrefix = process.env.NODE_ENV !== 'production' ? `${timestamp} ` : '';
35+
const timestampPrefix = config.get('@opentermsarchive/engine.logger.timestampPrefix') ? `${timestamp} ` : '';
3636

3737
return `${timestampPrefix}${level.padEnd(15)} ${message}`;
3838
}),

src/logger/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const alignedWithColorsAndTime = combine(
1616

1717
const truncatedPrefix = servicePrefix.length > 75 ? `${servicePrefix.slice(0, 74)}…` : servicePrefix;
1818

19-
const timestampPrefix = process.env.NODE_ENV !== 'production' ? `${timestamp} ` : '';
19+
const timestampPrefix = config.get('@opentermsarchive/engine.logger.timestampPrefix') ? `${timestamp} ` : '';
2020

2121
return `${timestampPrefix}${level.padEnd(15)} ${truncatedPrefix.padEnd(75)} ${message}`;
2222
}),

0 commit comments

Comments
 (0)