Skip to content

Commit

Permalink
[FAB-8029] Fix some log messages
Browse files Browse the repository at this point in the history
Some log messages including format verbs are printed by log.Debug,
not by log.Debugf. Hence the log messages have garbage “%s”.
This CR fixes such log messages and also changes log messages
including format verbs that do not use log.Debugf.

Change-Id: I9369cc459ca02215d898e7035660beffbd4633c8
Signed-off-by: Nao Nishijima <[email protected]>
  • Loading branch information
Nao Nishijima committed Feb 12, 2018
1 parent 6ab4936 commit bd695ae
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/attr/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func checkHfRegistrarAttrValues(reqAttr *api.Attribute, reqAttrs []api.Attribute
}

func canRegisterAttr(requestedAttrName string, callerRegisterAttrSlice []string) error {
log.Debug("Checking if registrar can register attribute: %s", requestedAttrName)
log.Debugf("Checking if registrar can register attribute: %s", requestedAttrName)

for _, regAttr := range callerRegisterAttrSlice {
if strings.HasSuffix(regAttr, "*") { // Wildcard matching
Expand Down
2 changes: 1 addition & 1 deletion lib/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ func (ca *CA) initUserRegistry() error {
if ldapCfg.Enabled {
// Use LDAP for the user registry
ca.registry, err = ldap.NewClient(ldapCfg, ca.server.csp)
log.Debug("Initialized LDAP identity registry; err=", err)
log.Debugf("Initialized LDAP identity registry; err=%s", err)
if err == nil {
log.Info("Successfully initialized LDAP client")
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/certdbaccessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (d *CertDBAccessor) InsertCertificate(cr certdb.CertificateRecord) error {
serial := util.GetSerialAsHex(ip)
aki := strings.TrimLeft(cr.AKI, "0")

log.Debug("Saved serial number as hex ", serial)
log.Debugf("Saved serial number as hex %s", serial)

var record = new(CertRecord)
record.ID = id
Expand Down
2 changes: 1 addition & 1 deletion lib/dbaccessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func (d *Accessor) deleteAffiliationTx(tx *sqlx.Tx, args ...interface{}) (interf
}
}

log.Debug("All affiliations to be removed: ", allAffs)
log.Debugf("All affiliations to be removed: %s", allAffs)

// Delete the requested affiliation
_, err = tx.Exec(tx.Rebind(deleteAffiliation), name)
Expand Down
8 changes: 4 additions & 4 deletions lib/dbutil/dbutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func NewUserRegistryPostgres(datasource string, clientTLSConfig *tls.ClientTLSCo
log.Debugf("Using postgres database, connecting to database...")

dbName := getDBName(datasource)
log.Debug("Database Name: ", dbName)
log.Debugf("Database Name: %s", dbName)

if strings.Contains(dbName, "-") || strings.HasSuffix(dbName, ".db") {
return nil, errors.Errorf("Database name '%s' cannot contain any '-' or end with '.db'", dbName)
Expand All @@ -166,7 +166,7 @@ func NewUserRegistryPostgres(datasource string, clientTLSConfig *tls.ClientTLSCo

for _, dbName := range dbNames {
connStr := getConnStr(datasource, dbName)
log.Debug("Connecting to PostgreSQL server, using connection string: ", MaskDBCred(connStr))
log.Debugf("Connecting to PostgreSQL server, using connection string: %s", MaskDBCred(connStr))

db, err = sqlx.Open("postgres", connStr)
if err != nil {
Expand Down Expand Up @@ -249,7 +249,7 @@ func NewUserRegistryMySQL(datasource string, clientTLSConfig *tls.ClientTLSConfi
log.Debugf("Using MySQL database, connecting to database...")

dbName := getDBName(datasource)
log.Debug("Database Name: ", dbName)
log.Debugf("Database Name: %s", dbName)

re := regexp.MustCompile(`\/([0-9,a-z,A-Z$_]+)`)
connStr := re.ReplaceAllString(datasource, "/")
Expand All @@ -263,7 +263,7 @@ func NewUserRegistryMySQL(datasource string, clientTLSConfig *tls.ClientTLSConfi
mysql.RegisterTLSConfig("custom", tlsConfig)
}

log.Debug("Connecting to MySQL server, using connection string: ", MaskDBCred(connStr))
log.Debugf("Connecting to MySQL server, using connection string: %s", MaskDBCred(connStr))
db, err := sqlx.Open("mysql", connStr)
if err != nil {
return nil, errors.Wrap(err, "Failed to open MySQL database")
Expand Down
2 changes: 1 addition & 1 deletion lib/serverregister.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func registerUserID(req *api.RegistrationRequest, ca *CA) (string, error) {
}

func isValidAffiliation(affiliation string, ca *CA) error {
log.Debug("Validating affiliation: " + affiliation)
log.Debugf("Validating affiliation: %s", affiliation)

// If requested affiliation is for root then don't need to do lookup in affiliation's table
if affiliation == "" {
Expand Down
2 changes: 1 addition & 1 deletion lib/serverrequestcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func (ctx *serverRequestContext) canActOnType(requestedType string) (bool, error
}

if !util.StrContained(requestedType, types) {
log.Debug("Caller with types '%s' is not authorized to act on '%s'", types, requestedType)
log.Debugf("Caller with types '%s' is not authorized to act on '%s'", types, requestedType)
return false, nil
}

Expand Down

0 comments on commit bd695ae

Please sign in to comment.