1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00

Merge pull request #429 from endophage/json_logs

using JSON logging format
This commit is contained in:
David Lawrence
2016-01-07 11:53:48 -08:00
2 changed files with 19 additions and 1 deletions

View File

@@ -28,10 +28,14 @@ import (
)
// DebugAddress is the debug server address to listen on
const DebugAddress = "localhost:8080"
const (
jsonLogFormat = "json"
DebugAddress = "localhost:8080"
)
var (
debug bool
logFormat string
configFile string
envPrefix = "NOTARY_SERVER"
mainViper = viper.New()
@@ -42,6 +46,12 @@ func init() {
// Setup flags
flag.StringVar(&configFile, "config", "", "Path to configuration file")
flag.BoolVar(&debug, "debug", false, "Enable the debugging server on localhost:8080")
flag.StringVar(&logFormat, "logf", "json", "Set the format of the logs. Only 'json' and 'logfmt' are supported at the moment.")
// this needs to be in init so that _ALL_ logs are in the correct format
if logFormat == jsonLogFormat {
logrus.SetFormatter(new(logrus.JSONFormatter))
}
}
// get the address for the HTTP server, and parses the optional TLS

View File

@@ -37,6 +37,7 @@ import (
)
const (
jsonLogFormat = "json"
debugAddr = "localhost:8080"
envPrefix = "NOTARY_SIGNER"
defaultAliasEnv = "DEFAULT_ALIAS"
@@ -44,6 +45,7 @@ const (
var (
debug bool
logFormat string
configFile string
mainViper = viper.New()
)
@@ -53,6 +55,12 @@ func init() {
// Setup flags
flag.StringVar(&configFile, "config", "", "Path to configuration file")
flag.BoolVar(&debug, "debug", false, "show the version and exit")
flag.StringVar(&logFormat, "logf", "json", "Set the format of the logs. Only 'json' and 'logfmt' are supported at the moment.")
// this needs to be in init so that _ALL_ logs are in the correct format
if logFormat == jsonLogFormat {
logrus.SetFormatter(new(logrus.JSONFormatter))
}
}
func passphraseRetriever(keyName, alias string, createNew bool, attempts int) (passphrase string, giveup bool, err error) {