Skip to content

Commit a35f742

Browse files
committed
Further refactoring: Move to new logging style but still with stdlog.
1 parent e204b84 commit a35f742

File tree

4 files changed

+54
-54
lines changed

4 files changed

+54
-54
lines changed

imap/connection.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ func (c *Connection) InternalSend(inc bool, text string) error {
9999
// Test if connection is still healthy.
100100
_, err := conn.Write([]byte("> ping <\r\n"))
101101
if err != nil {
102-
return fmt.Errorf("sending ping to node '%s' failed: %s", conn.RemoteAddr().String(), err.Error())
102+
return fmt.Errorf("sending ping to node '%s' failed: %v", conn.RemoteAddr().String(), err)
103103
}
104104

105105
// Write message to TLS connections.
106106
_, err = fmt.Fprintf(conn, "%s\r\n", text)
107107
for err != nil {
108108

109-
stdlog.Printf("[imap.InternalSend] Sending to node '%s' failed, trying to recover...\n", conn.RemoteAddr())
109+
stdlog.Printf("[imap.InternalSend] Sending to node '%s' failed, trying to recover...", conn.RemoteAddr())
110110

111111
// Define what IP and port of remote node look like.
112112
remoteAddr := conn.RemoteAddr().String()
@@ -119,7 +119,7 @@ func (c *Connection) InternalSend(inc bool, text string) error {
119119
// Reestablish TLS connection to remote node.
120120
conn, err = comm.ReliableConnect(remoteAddr, c.IntlTLSConfig, c.IntlConnRetry)
121121
if err != nil {
122-
return fmt.Errorf("failed to reestablish connection with '%s': %s", remoteAddr, err.Error())
122+
return fmt.Errorf("failed to reestablish connection with '%s': %v", remoteAddr, err)
123123
}
124124

125125
// Save context to connection.
@@ -133,16 +133,16 @@ func (c *Connection) InternalSend(inc bool, text string) error {
133133
// Inform remote node about which session was active.
134134
err = c.SignalSessionStart(false)
135135
if err != nil {
136-
return fmt.Errorf("signalling session to remote node failed with: %s", err.Error())
136+
return fmt.Errorf("signalling session to remote node failed with: %v", err)
137137
}
138138
}
139139

140-
stdlog.Printf("[imap.InternalSend] Reconnected to '%s'.\n", remoteAddr)
140+
stdlog.Printf("[imap.InternalSend] Reconnected to '%s'.", remoteAddr)
141141

142142
// Resend message to remote node.
143143
_, err = fmt.Fprintf(conn, "%s\r\n", text)
144144
} else {
145-
return fmt.Errorf("failed to send message to remote node '%s': %s", remoteAddr, err.Error())
145+
return fmt.Errorf("failed to send message to remote node '%s': %v", remoteAddr, err)
146146
}
147147
}
148148

@@ -177,7 +177,7 @@ func (c *Connection) Receive(inc bool) (string, error) {
177177
if err != nil {
178178

179179
if err.Error() == "EOF" {
180-
stdlog.Printf("[imap.Receive] Node at '%s' disconnected.\n", conn.RemoteAddr().String())
180+
stdlog.Printf("[imap.Receive] Node at '%s' disconnected.", conn.RemoteAddr().String())
181181
}
182182

183183
break
@@ -320,7 +320,7 @@ func (c *Connection) Terminate() error {
320320
func (c *Connection) Error(msg string, err error) {
321321

322322
// Log error.
323-
stdlog.Printf("%s: %s. Terminating connection to %s.\n", msg, err.Error(), c.IncConn.RemoteAddr().String())
323+
stdlog.Printf("%s: %v. Terminating connection to %s.", msg, err, c.IncConn.RemoteAddr().String())
324324

325325
// Terminate connection.
326326
err = c.Terminate()

imap/distributor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func InitDistributor(logger log.Logger, config *config.Config, auth PlainAuthent
7979
// Start to listen for incoming public connections on defined IP and port.
8080
distr.Socket, err = tls.Listen("tcp", fmt.Sprintf("%s:%s", config.Distributor.ListenIP, config.Distributor.Port), publicTLSConfig)
8181
if err != nil {
82-
return nil, fmt.Errorf("[imap.InitDistributor] Listening for public TLS connections failed with: %s\n", err.Error())
82+
return nil, fmt.Errorf("[imap.InitDistributor] Listening for public TLS connections failed with: %v", err)
8383
}
8484

8585
level.Info(logger).Log(
@@ -100,7 +100,7 @@ func (distr *Distributor) Run() error {
100100
// Accept request or fail on error.
101101
conn, err := distr.Socket.Accept()
102102
if err != nil {
103-
return fmt.Errorf("[imap.Run] Accepting incoming request at distributor failed with: %s\n", err.Error())
103+
return fmt.Errorf("[imap.Run] Accepting incoming request at distributor failed with: %v", err)
104104
}
105105

106106
// Dispatch into own goroutine.

0 commit comments

Comments
 (0)