diff --git a/CHANGELOG.md b/CHANGELOG.md index ecae9e0..9ea094b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,13 @@ All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the [engine CONTRIBUTING file](https://github.com/OpenTermsArchive/engine/blob/main/CONTRIBUTING.md#changelog). This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## Unreleased [minor] + +> Development of this release was supported by the [French Ministry for Foreign Affairs](https://www.diplomatie.gouv.fr/fr/politique-etrangere-de-la-france/diplomatie-numerique/) through its ministerial [State Startups incubator](https://beta.gouv.fr/startups/open-terms-archive.html) under the aegis of the Ambassador for Digital Affairs. + +### Added + +- Add configuration option to toggle timestamp prefix in logs; set [`@opentermsarchive/federation-api.logger.timestampPrefix` to `true` or `false` in your configuration file](https://docs.opentermsarchive.org/api/federation/#configuring) to control this feature. ## 2.0.0 - 2024-06-13 diff --git a/config/default.json b/config/default.json index ddac7ff..3c341d9 100644 --- a/config/default.json +++ b/config/default.json @@ -8,7 +8,8 @@ "host": "smtp-relay.sendinblue.com", "username": "admin@opentermsarchive.org" }, - "sendMailOnError": false + "sendMailOnError": false, + "timestampPrefix": true } } } diff --git a/src/utils/logger.js b/src/utils/logger.js index 52f244d..1bddd2f 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -11,8 +11,12 @@ const transports = [new winston.transports.Console({ silent: process.env.NODE_EN const logger = winston.createLogger({ format: combine( colorize(), - timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), - printf(({ level, message, timestamp }) => `${timestamp} ${level.padEnd(15)} ${message}`), + timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }), + printf(({ level, message, timestamp }) => { + const timestampPrefix = config.get('@opentermsarchive/federation-api.logger.timestampPrefix') ? `${timestamp} ` : ''; + + return `${timestampPrefix}${level.padEnd(15)} ${message}`; + }), ), transports, rejectionHandlers: transports,