Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up default log level, key import/export logs #1179

Merged
merged 2 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/notary/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1725,12 +1725,12 @@ func TestLogLevelFlags(t *testing.T) {
// Test default to fatal
n := notaryCommander{}
n.setVerbosityLevel()
require.Equal(t, "fatal", logrus.GetLevel().String())
require.Equal(t, "warning", logrus.GetLevel().String())

// Test that verbose (-v) sets to error
n.verbose = true
n.setVerbosityLevel()
require.Equal(t, "error", logrus.GetLevel().String())
require.Equal(t, "info", logrus.GetLevel().String())

// Test that debug (-D) sets to debug
n.debug = true
Expand Down
6 changes: 3 additions & 3 deletions cmd/notary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ func getPassphraseRetriever() notary.PassRetriever {
}
}

// Set the logging level to fatal on default, or the most specific level the user specified (debug or error)
// Set the logging level to warn on default, or the most verbose level the user specified (debug, info)
func (n *notaryCommander) setVerbosityLevel() {
if n.debug {
logrus.SetLevel(logrus.DebugLevel)
} else if n.verbose {
logrus.SetLevel(logrus.ErrorLevel)
logrus.SetLevel(logrus.InfoLevel)
} else {
logrus.SetLevel(logrus.FatalLevel)
logrus.SetLevel(logrus.WarnLevel)
}
logrus.SetOutput(os.Stderr)
}
6 changes: 3 additions & 3 deletions utils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ExportKeysByGUN(to io.Writer, s Exporter, gun string) error {
for _, loc := range keys {
keyFile, err := s.Get(loc)
if err != nil {
logrus.Info("Could not parse key file at ", loc)
logrus.Warn("Could not parse key file at ", loc)
continue
}
block, _ := pem.Decode(keyFile)
Expand Down Expand Up @@ -203,7 +203,7 @@ func checkValidity(block *pem.Block) (string, error) {
case tufdata.CanonicalSnapshotRole.String(), tufdata.CanonicalTargetsRole.String(), tufdata.CanonicalTimestampRole.String():
// check if the key is missing a gun header or has an empty gun and error out since we don't know what gun it belongs to
if block.Headers["gun"] == "" {
logrus.Infof("failed to import key (%s) to store: Cannot have canonical role key without a gun, don't know what gun it belongs to", block.Headers["path"])
logrus.Warnf("failed to import key (%s) to store: Cannot have canonical role key without a gun, don't know what gun it belongs to", block.Headers["path"])
return "", errors.New("invalid key pem block")
}
default:
Expand All @@ -219,7 +219,7 @@ func checkValidity(block *pem.Block) (string, error) {

decodedKey, err := utils.ParsePEMPrivateKey(pem.EncodeToMemory(block), "")
if err != nil {
logrus.Info("failed to import key to store: Invalid key generated, key may be encrypted and does not contain path header")
logrus.Warn("failed to import key to store: Invalid key generated, key may be encrypted and does not contain path header")
return "", errors.New("invalid key pem block")
}
loc = decodedKey.ID()
Expand Down