Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Fix logging of where application is bound #2249

Merged
merged 2 commits into from
May 1, 2022
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
5 changes: 2 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import (
func (a *App) Serve(srvs ...servers.Server) error {
var wg sync.WaitGroup

// FIXME: this information is not correct.
// It needs to be fixed as we support multiple servers.
a.Logger.Infof("starting application at http://%s", a.Options.Addr)
hut8 marked this conversation as resolved.
Show resolved Hide resolved
a.Logger.Debug("starting application")

payload := events.Payload{
"app": a,
Expand Down Expand Up @@ -98,6 +96,7 @@ func (a *App) Serve(srvs ...servers.Server) error {

for _, s := range srvs {
s.SetAddr(a.Addr)
a.Logger.Infof("starting %s", s)
wg.Add(1)
go func(s servers.Server) {
defer wg.Done()
Expand Down
6 changes: 6 additions & 0 deletions servers/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package servers

import (
"context"
"fmt"
"net"
"net/http"
)
Expand All @@ -19,6 +20,11 @@ func (s *Listener) SetAddr(addr string) {
}
}

// String returns a string representation of a Listener
func (s *Listener) String() string {
return fmt.Sprintf("listener on %s", s.Server.Addr)
}

// Start the server
func (s *Listener) Start(c context.Context, h http.Handler) error {
s.Handler = h
Expand Down
6 changes: 6 additions & 0 deletions servers/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package servers

import (
"context"
"fmt"
"net/http"
)

Expand All @@ -17,6 +18,11 @@ func (s *Simple) SetAddr(addr string) {
}
}

// String returns a string representation of a Simple server
func (s *Simple) String() string {
return fmt.Sprintf("simple server on %s", s.Server.Addr)
}

// Start the server
func (s *Simple) Start(c context.Context, h http.Handler) error {
s.Handler = h
Expand Down
6 changes: 6 additions & 0 deletions servers/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package servers

import (
"context"
"fmt"
"net/http"
)

Expand All @@ -19,6 +20,11 @@ func (s *TLS) SetAddr(addr string) {
}
}

// String returns a string representation of a Listener
func (s *TLS) String() string {
return fmt.Sprintf("TLS server on %s", s.Server.Addr)
}

// Start the server
func (s *TLS) Start(c context.Context, h http.Handler) error {
s.Handler = h
Expand Down