@@ -36,6 +36,7 @@ func New(cfg *config.Config) {
36
36
37
37
engine := echo .New ()
38
38
engine .HideBanner = true
39
+ engine .HidePort = true
39
40
40
41
if cfg .App .AppMode == "development" {
41
42
engine .Debug = true
@@ -51,14 +52,37 @@ func New(cfg *config.Config) {
51
52
52
53
if cfg .Logging .RequestLogging {
53
54
logger .Debug ("request logging is enabled" )
54
- logCfg := middleware .DefaultLoggerConfig
55
+ // DH: We might want to make these fields user configurable at some point
56
+ logCfg := middleware.RequestLoggerConfig {
57
+ LogLatency : true ,
58
+ LogRemoteIP : true ,
59
+ LogHost : true ,
60
+ LogMethod : true ,
61
+ LogURI : true ,
62
+ LogUserAgent : true ,
63
+ LogStatus : true ,
64
+ LogResponseSize : true ,
65
+ LogValuesFunc : func (c echo.Context , v middleware.RequestLoggerValues ) error {
66
+ logger .Info ("request" ,
67
+ zap .String ("remote_ip" , v .RemoteIP ),
68
+ zap .String ("host" , v .Host ),
69
+ zap .String ("method" , v .Method ),
70
+ zap .String ("uri" , v .URI ),
71
+ zap .Int ("status" , v .Status ),
72
+ zap .Int64 ("latency_ms" , v .Latency .Milliseconds ()),
73
+ zap .Int64 ("response_bytes" , v .ResponseSize ),
74
+ zap .String ("user_agent" , v .UserAgent ),
75
+ )
76
+ return nil
77
+ },
78
+ }
55
79
if ! cfg .Logging .LogHealthChecks {
56
80
logger .Debug ("log_health_checks = false; requests to health check endpoint will not be logged" )
57
81
logCfg .Skipper = func (c echo.Context ) bool {
58
82
return c .Path () == cfg .Server .BasePath + "/api/health"
59
83
}
60
84
}
61
- engine .Use (middleware .LoggerWithConfig (logCfg ))
85
+ engine .Use (middleware .RequestLoggerWithConfig (logCfg ))
62
86
}
63
87
64
88
if cfg .Server .EnableGzip {
0 commit comments