6
6
"crypto/tls"
7
7
"errors"
8
8
"fmt"
9
+ ginlogrus "github.com/toorop/gin-logrus"
9
10
"net/http"
10
11
"os"
11
12
"os/signal"
@@ -18,7 +19,6 @@ import (
18
19
"github.com/prometheus/client_golang/prometheus/promhttp"
19
20
"github.com/puppetlabs/go-libs/internal/log"
20
21
"github.com/sirupsen/logrus"
21
- ginlogrus "github.com/toorop/gin-logrus"
22
22
)
23
23
24
24
const (
@@ -31,6 +31,7 @@ const (
31
31
// Config will hold the configuration of the service.
32
32
type Config struct {
33
33
ListenAddress string // Address in the format [host/ip]:port. Mandatory.
34
+ DisableLog bool // Turn off service logging. Default is false.
34
35
LogLevel string // INFO,FATAL,ERROR,WARN, DEBUG, TRACE.
35
36
Cors * CorsConfig // Optional cors config.
36
37
ReadinessCheck bool // Set to true to add a readiness handler at /readiness.
@@ -251,8 +252,11 @@ func NewService(cfg *Config) (*Service, error) {
251
252
252
253
gin .SetMode (gin .ReleaseMode )
253
254
router := gin .New ()
254
- logger := log .CreateLogger (cfg .LogLevel )
255
- router .Use (ginlogrus .Logger (logger , cfg .LogIgnorePaths ... ))
255
+
256
+ if ! cfg .DisableLog {
257
+ logger := log .CreateLogger (cfg .LogLevel )
258
+ router .Use (ginlogrus .Logger (logger , cfg .LogIgnorePaths ... ))
259
+ }
256
260
257
261
// Set CORS to the default if it's enabled and no override passed in.
258
262
setupCors (router , cfg .Cors )
0 commit comments