Skip to content

Commit 211bb65

Browse files
committed
Add new environment variable for logging format
This CR removes the logging format from core.yaml and replaces it with a new environment variable, FABRIC_LOGGING_FORMAT. FAB-12511 #done Change-Id: I2b932640d8b44dfd3a6cfdfff5239a29cc54e589 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent f1c5da6 commit 211bb65

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

peer/common/common.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,23 @@ func InitCmd(cmd *cobra.Command, args []string) {
278278
os.Exit(1)
279279
}
280280

281-
// check for --logging-level pflag first, which should override all other
282-
// log settings. if --logging-level is not set, use CORE_LOGGING_LEVEL
283-
// (environment variable takes priority; otherwise, the value set in
284-
// core.yaml)
281+
// read in the legacy logging level settings and, if set,
282+
// notify users of the FABRIC_LOGGING_SPEC env variable
285283
var loggingLevel string
286284
if viper.GetString("logging_level") != "" {
287285
loggingLevel = viper.GetString("logging_level")
288286
} else {
289287
loggingLevel = viper.GetString("logging.level")
290288
}
291-
loggingSpec := os.Getenv("FABRIC_LOGGING_SPEC")
292289
if loggingLevel != "" {
293-
mainLogger.Warning("CORE_LOGGING_LEVEL is no longer supported, please use FABRIC_LOGGING_SPEC environment variable.")
290+
mainLogger.Warning("CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable")
294291
}
295292

293+
loggingSpec := os.Getenv("FABRIC_LOGGING_SPEC")
294+
loggingFormat := os.Getenv("FABRIC_LOGGING_FORMAT")
295+
296296
flogging.Init(flogging.Config{
297-
Format: viper.GetString("logging.format"),
297+
Format: loggingFormat,
298298
Writer: logOutput,
299299
LogSpec: loggingSpec,
300300
})

sampleconfig/core.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

6-
###############################################################################
7-
#
8-
# LOGGING section
9-
#
10-
###############################################################################
11-
logging:
12-
13-
# Message format for the peer logs
14-
format: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'
15-
166
###############################################################################
177
#
188
# Peer section

0 commit comments

Comments
 (0)