Skip to content

Commit 2ba703e

Browse files
committed
Clean up initial log statements
1. In RunTLS, only print the initial log statement if `Listen` is successful. Also, print the actual address instead of the one passed in. 2. Change `l.Addr().String()` to `l.Addr()`. The Addr interface has a `String` method, which will be called by fmt.
1 parent 1414174 commit 2ba703e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

server.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (s *Server) Run(addr string) {
150150
log.Fatal("ListenAndServe:", err)
151151
}
152152

153-
s.Logger.Printf("web.go serving %s\n", l.Addr().String())
153+
s.Logger.Printf("web.go serving %s\n", l.Addr())
154154

155155
s.l = l
156156
err = http.Serve(s.l, mux)
@@ -177,13 +177,12 @@ func (s *Server) RunTLS(addr string, config *tls.Config) error {
177177
mux := http.NewServeMux()
178178
mux.Handle("/", s)
179179

180-
s.Logger.Printf("web.go serving %s\n", addr)
181-
182180
l, err := tls.Listen("tcp", addr, config)
183181
if err != nil {
184182
log.Fatal("Listen:", err)
185183
return err
186184
}
185+
s.Logger.Printf("web.go serving %s\n", l.Addr())
187186

188187
s.l = l
189188
return http.Serve(s.l, mux)

0 commit comments

Comments
 (0)