3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

avoid some uses of Sprintf for loglines

This commit is contained in:
Shivaram Lingamneni 2018-12-31 11:33:42 -05:00
parent ec4f1c189a
commit c2b2559ab4
6 changed files with 11 additions and 11 deletions

View File

@ -99,7 +99,7 @@ func (am *AccountManager) buildNickToAccountIndex() {
}) })
if err != nil { if err != nil {
am.server.logger.Error("internal", fmt.Sprintf("couldn't read reserved nicks: %v", err)) am.server.logger.Error("internal", "couldn't read reserved nicks", err.Error())
} else { } else {
am.Lock() am.Lock()
am.nickToAccount = result am.nickToAccount = result
@ -286,14 +286,14 @@ func (am *AccountManager) serializeCredentials(passphrase string, certfp string)
bcryptCost := int(am.server.Config().Accounts.Registration.BcryptCost) bcryptCost := int(am.server.Config().Accounts.Registration.BcryptCost)
creds.PassphraseHash, err = passwd.GenerateFromPassword([]byte(passphrase), bcryptCost) creds.PassphraseHash, err = passwd.GenerateFromPassword([]byte(passphrase), bcryptCost)
if err != nil { if err != nil {
am.server.logger.Error("internal", fmt.Sprintf("could not hash password: %v", err)) am.server.logger.Error("internal", "could not hash password", err.Error())
return "", errAccountCreation return "", errAccountCreation
} }
} }
credText, err := json.Marshal(creds) credText, err := json.Marshal(creds)
if err != nil { if err != nil {
am.server.logger.Error("internal", fmt.Sprintf("could not marshal credentials: %v", err)) am.server.logger.Error("internal", "could not marshal credentials", err.Error())
return "", errAccountCreation return "", errAccountCreation
} }
return string(credText), nil return string(credText), nil
@ -367,7 +367,7 @@ func (am *AccountManager) dispatchMailtoCallback(client *Client, casefoldedAccou
// config.TLS.InsecureSkipVerify // config.TLS.InsecureSkipVerify
err = smtp.SendMail(addr, auth, config.Sender, []string{callbackValue}, message) err = smtp.SendMail(addr, auth, config.Sender, []string{callbackValue}, message)
if err != nil { if err != nil {
am.server.logger.Error("internal", fmt.Sprintf("Failed to dispatch e-mail: %v", err)) am.server.logger.Error("internal", "Failed to dispatch e-mail", err.Error())
} }
return return
} }
@ -619,7 +619,7 @@ func (am *AccountManager) deserializeRawAccount(raw rawClientAccount) (result Cl
result.RegisteredAt = time.Unix(regTimeInt, 0) result.RegisteredAt = time.Unix(regTimeInt, 0)
e := json.Unmarshal([]byte(raw.Credentials), &result.Credentials) e := json.Unmarshal([]byte(raw.Credentials), &result.Credentials)
if e != nil { if e != nil {
am.server.logger.Error("internal", fmt.Sprintf("could not unmarshal credentials: %v", e)) am.server.logger.Error("internal", "could not unmarshal credentials", e.Error())
err = errAccountDoesNotExist err = errAccountDoesNotExist
return return
} }
@ -628,7 +628,7 @@ func (am *AccountManager) deserializeRawAccount(raw rawClientAccount) (result Cl
if raw.VHost != "" { if raw.VHost != "" {
e := json.Unmarshal([]byte(raw.VHost), &result.VHost) e := json.Unmarshal([]byte(raw.VHost), &result.VHost)
if e != nil { if e != nil {
am.server.logger.Warning("internal", fmt.Sprintf("could not unmarshal vhost for account %s: %v", result.Name, e)) am.server.logger.Warning("internal", "could not unmarshal vhost for account", result.Name, e.Error())
// pretend they have no vhost and move on // pretend they have no vhost and move on
} }
} }

View File

@ -48,7 +48,7 @@ type Channel struct {
func NewChannel(s *Server, name string, regInfo *RegisteredChannel) *Channel { func NewChannel(s *Server, name string, regInfo *RegisteredChannel) *Channel {
casefoldedName, err := CasefoldChannel(name) casefoldedName, err := CasefoldChannel(name)
if err != nil { if err != nil {
s.logger.Error("internal", fmt.Sprintf("Bad channel name %s: %v", name, err)) s.logger.Error("internal", "Bad channel name", name, err.Error())
return nil return nil
} }

View File

@ -72,7 +72,7 @@ func (clients *ClientManager) removeInternal(client *Client) (err error) {
delete(clients.byNick, oldcfnick) delete(clients.byNick, oldcfnick)
} else { } else {
// this shouldn't happen, but we can ignore it // this shouldn't happen, but we can ignore it
client.server.logger.Warning("internal", fmt.Sprintf("clients for nick %s out of sync", oldcfnick)) client.server.logger.Warning("internal", "clients for nick out of sync", oldcfnick)
err = errNickMissing err = errNickMissing
} }
} }

View File

@ -367,7 +367,7 @@ func authErrorToMessage(server *Server, err error) (msg string) {
if err == errAccountDoesNotExist || err == errAccountUnverified || err == errAccountInvalidCredentials { if err == errAccountDoesNotExist || err == errAccountUnverified || err == errAccountInvalidCredentials {
msg = err.Error() msg = err.Error()
} else { } else {
server.logger.Error("internal", fmt.Sprintf("sasl authentication failure: %v", err)) server.logger.Error("internal", "sasl authentication failure", err.Error())
msg = "Unknown" msg = "Unknown"
} }
return return

View File

@ -443,7 +443,7 @@ func nsPasswdHandler(server *Server, client *Client, command, params string, rb
if err == nil { if err == nil {
nsNotice(rb, client.t("Password changed")) nsNotice(rb, client.t("Password changed"))
} else { } else {
server.logger.Error("internal", fmt.Sprintf("could not upgrade user password: %v", err)) server.logger.Error("internal", "could not upgrade user password:", err.Error())
nsNotice(rb, client.t("Password could not be changed due to server error")) nsNotice(rb, client.t("Password could not be changed due to server error"))
} }
} }

View File

@ -836,7 +836,7 @@ func (server *Server) setupPprofListener(config *Config) {
} }
go func() { go func() {
if err := ps.ListenAndServe(); err != nil { if err := ps.ListenAndServe(); err != nil {
server.logger.Error("rehash", fmt.Sprintf("pprof listener failed: %v", err)) server.logger.Error("rehash", "pprof listener failed", err.Error())
} }
}() }()
server.pprofServer = &ps server.pprofServer = &ps