diff options
author | Nick Thomas <nick@gitlab.com> | 2018-03-07 15:07:01 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-03-07 15:07:01 +0300 |
commit | 1ae4901c7ea49c4eec8cc26d68ad85c5c8719454 (patch) | |
tree | 462ff00bf05f56e04418d3d0d2cfcc59ec8fe45e /app.go | |
parent | 0b69e09383eb22a8904bfed1479800d13f7325a4 (diff) | |
parent | 64f6d823b4ce2656047ffca2844ef4d6cf79ec77 (diff) |
Merge branch 'structured-logging' into 'master'
Structured logging
See merge request gitlab-org/gitlab-pages!56
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -2,7 +2,6 @@ package main import ( "crypto/tls" - "log" "net" "net/http" "strconv" @@ -14,6 +13,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/cors" + log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitlab-pages/internal/artifact" "gitlab.com/gitlab-org/gitlab-pages/internal/httperrors" @@ -151,7 +151,7 @@ func (a *theApp) Run() { defer wg.Done() err := listenAndServe(fd, a.ServeHTTP, a.HTTP2, nil) if err != nil { - log.Fatal(err) + fatal(err) } }(fd) } @@ -163,7 +163,7 @@ func (a *theApp) Run() { defer wg.Done() err := listenAndServeTLS(fd, a.RootCertificate, a.RootKey, a.ServeHTTP, a.ServeTLS, a.HTTP2) if err != nil { - log.Fatal(err) + fatal(err) } }(fd) } @@ -175,7 +175,7 @@ func (a *theApp) Run() { defer wg.Done() err := listenAndServe(fd, a.ServeProxy, a.HTTP2, nil) if err != nil { - log.Fatal(err) + fatal(err) } }(fd) } @@ -189,7 +189,7 @@ func (a *theApp) Run() { handler := promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}).ServeHTTP err := listenAndServe(fd, handler, false, nil) if err != nil { - log.Fatal(err) + fatal(err) } }(a.ListenMetrics) } @@ -200,14 +200,17 @@ func (a *theApp) Run() { } func runApp(config appConfig) { - if err := mimedb.LoadTypes(); err != nil { - log.Printf("WARNING: Loading extended MIME database failed: %v", err) - } - a := theApp{appConfig: config} if config.ArtifactsServer != "" { a.Artifact = artifact.New(config.ArtifactsServer, config.ArtifactsServerTimeout, config.Domain) } + + configureLogging(config.LogFormat) + + if err := mimedb.LoadTypes(); err != nil { + log.WithError(err).Warn("Loading extended MIME database failed") + } + a.Run() } |