Skip to content

Commit

Permalink
Add new environment variable for logging format
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wlahti committed Oct 31, 2018
1 parent f1c5da6 commit 211bb65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
14 changes: 7 additions & 7 deletions peer/common/common.go
Expand Up @@ -278,23 +278,23 @@ func InitCmd(cmd *cobra.Command, args []string) {
os.Exit(1)
}

// check for --logging-level pflag first, which should override all other
// log settings. if --logging-level is not set, use CORE_LOGGING_LEVEL
// (environment variable takes priority; otherwise, the value set in
// core.yaml)
// read in the legacy logging level settings and, if set,
// notify users of the FABRIC_LOGGING_SPEC env variable
var loggingLevel string
if viper.GetString("logging_level") != "" {
loggingLevel = viper.GetString("logging_level")
} else {
loggingLevel = viper.GetString("logging.level")
}
loggingSpec := os.Getenv("FABRIC_LOGGING_SPEC")
if loggingLevel != "" {
mainLogger.Warning("CORE_LOGGING_LEVEL is no longer supported, please use FABRIC_LOGGING_SPEC environment variable.")
mainLogger.Warning("CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable")
}

loggingSpec := os.Getenv("FABRIC_LOGGING_SPEC")
loggingFormat := os.Getenv("FABRIC_LOGGING_FORMAT")

flogging.Init(flogging.Config{
Format: viper.GetString("logging.format"),
Format: loggingFormat,
Writer: logOutput,
LogSpec: loggingSpec,
})
Expand Down
10 changes: 0 additions & 10 deletions sampleconfig/core.yaml
Expand Up @@ -3,16 +3,6 @@
# SPDX-License-Identifier: Apache-2.0
#

###############################################################################
#
# LOGGING section
#
###############################################################################
logging:

# Message format for the peer logs
format: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'

###############################################################################
#
# Peer section
Expand Down

0 comments on commit 211bb65

Please sign in to comment.