From a70ac879fe1a59cdbe7ece0def92afc4e1e8991e Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Wed, 12 Feb 2025 07:58:47 -0300 Subject: [PATCH] FEATURE: add `shouldShowTime` Relates to [this forum request](https://forums.meteor.com/t/suggestions-for-logging-in-galaxy/63119/6?u=grubba). Those that use `colored-text` output format can now decide if they want the timestamp or can rely on their server/cloud environments info. --- packages/logging/logging.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/logging/logging.js b/packages/logging/logging.js index 889f173e6a..a816361327 100644 --- a/packages/logging/logging.js +++ b/packages/logging/logging.js @@ -44,6 +44,11 @@ Log._intercepted = () => { // other process that will be reading its standard output. Log.outputFormat = 'json'; +// Defaults to true for local development and for backwards compatibility. +// for cloud environments is interesting to leave it false as most of them have the timestamp in the console. +// Only works in server with colored-text +Log.shouldShowTime = true; + const LEVEL_COLORS = { debug: 'green', // leave info as the default color @@ -296,13 +301,15 @@ Log.format = (obj, options = {}) => { const stderrIndicator = stderr ? '(STDERR) ' : ''; + const timeString = Log.shouldShowTime + ? `${dateStamp}-${timeStamp}${utcOffsetStr}${timeInexact ? '? ' : ' '}` + : ' '; + + + const metaPrefix = [ level.charAt(0).toUpperCase(), - dateStamp, - '-', - timeStamp, - utcOffsetStr, - timeInexact ? '? ' : ' ', + timeString, appInfo, sourceInfo, stderrIndicator].join('');