Skip to content

Commit

Permalink
replace log.fatal with context logger
Browse files Browse the repository at this point in the history
  • Loading branch information
karinamzalez committed Jan 25, 2024
1 parent 17989fa commit eeaae91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ssas/service/api_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s *APICommonTestSuite) SetupSuite() {
func (s *APICommonTestSuite) TestJSONError() {
// JSON output is valid for simple strings
w := httptest.NewRecorder()
JSONError(w, http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized), "unauthorized")
JSONError(w, http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized), "unauthorized", nil)
resp := w.Result()
body, err := io.ReadAll(resp.Body)
assert.NoError(s.T(), err)
Expand Down
9 changes: 4 additions & 5 deletions ssas/service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
b64 "encoding/base64"
"errors"
"fmt"
"log"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -170,23 +169,23 @@ func (s *Server) Serve() {
logger := log2.GetCtxLogger(context.Background())
if s.notSecure {
logger.Infof("starting %s server running UNSAFE http only mode; do not do this in production environments", s.name)
go func() { log.Fatal(s.server.ListenAndServe()) }()
go func() { logger.Fatal(s.server.ListenAndServe()) }()
} else {
if s.useMTLS {
conf, err := BuildMTLSConfig()
if err != nil {
log.Fatal(err)
logger.Fatal(err)
}
s.server.TLSConfig = conf

//If cert and key file paths are not passed the certs in TLS configs are used.
logger.Infof("starting %s server in MTLS mode", s.name)
go func() { log.Fatal(s.server.ListenAndServeTLS("", "")) }()
go func() { logger.Fatal(s.server.ListenAndServeTLS("", "")) }()
} else {
tlsCertPath := os.Getenv("BCDA_TLS_CERT") // borrowing for now; we need to get our own (for both servers?)
tlsKeyPath := os.Getenv("BCDA_TLS_KEY")
logger.Infof("starting %s server in TLS mode", s.name)
go func() { log.Fatal(s.server.ListenAndServeTLS(tlsCertPath, tlsKeyPath)) }()
go func() { logger.Fatal(s.server.ListenAndServeTLS(tlsCertPath, tlsKeyPath)) }()
}
}
}
Expand Down

0 comments on commit eeaae91

Please sign in to comment.