@salesforce/core 8.13.0 → 8.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/logger/logger.js +8 -2
- package/package.json +1 -1
package/lib/logger/logger.js
CHANGED
|
@@ -391,11 +391,17 @@ class Logger {
|
|
|
391
391
|
exports.Logger = Logger;
|
|
392
392
|
/** return various streams that the logger could send data to, depending on the options and env */
|
|
393
393
|
const getWriteStream = (level = 'warn') => {
|
|
394
|
+
const env = new kit_1.Env();
|
|
394
395
|
// used when debug mode, writes to stdout (colorized)
|
|
395
396
|
if (process.env.DEBUG) {
|
|
396
397
|
return {
|
|
397
398
|
target: 'pino-pretty',
|
|
398
|
-
options: {
|
|
399
|
+
options: {
|
|
400
|
+
// NOTE: env.getBoolean() defaults to false if the env var is not set
|
|
401
|
+
// so it's important to use `||` instead of `??`
|
|
402
|
+
colorize: env.getBoolean('SF_LOG_COLORIZE') || true,
|
|
403
|
+
destination: env.getBoolean('SF_LOG_STDERR') ? 2 : 1,
|
|
404
|
+
},
|
|
399
405
|
};
|
|
400
406
|
}
|
|
401
407
|
// default: we're writing to a rotating file
|
|
@@ -404,7 +410,7 @@ const getWriteStream = (level = 'warn') => {
|
|
|
404
410
|
['1h', new Date().toISOString().split(':').slice(0, 1).join('-')],
|
|
405
411
|
['1d', new Date().toISOString().split('T')[0]],
|
|
406
412
|
]);
|
|
407
|
-
const logRotationPeriod =
|
|
413
|
+
const logRotationPeriod = env.getString('SF_LOG_ROTATION_PERIOD') ?? '1d';
|
|
408
414
|
return {
|
|
409
415
|
// write to a rotating file
|
|
410
416
|
target: 'pino/file',
|