summaryrefslogtreecommitdiff
path: root/cmd/rr/debug
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-15 15:54:14 +0300
committerWolfy-J <[email protected]>2018-06-15 15:54:14 +0300
commitdfef39c64132192d13e2315364a74f1b0244791e (patch)
treeb0959bbbb1ca5a16d94646454d7f2e9340081915 /cmd/rr/debug
parentccd297dbe2586b3fd29854f72f795be9e818522e (diff)
readme, samples, golint, build scripts
Diffstat (limited to 'cmd/rr/debug')
-rw-r--r--cmd/rr/debug/debugger.go (renamed from cmd/rr/debug/listener.go)28
1 files changed, 11 insertions, 17 deletions
diff --git a/cmd/rr/debug/listener.go b/cmd/rr/debug/debugger.go
index f137b06f..0621285b 100644
--- a/cmd/rr/debug/listener.go
+++ b/cmd/rr/debug/debugger.go
@@ -7,32 +7,32 @@ import (
"github.com/spiral/roadrunner/service/http"
)
-// Listener provide debug callback for system events. With colors!
-type listener struct{ logger *logrus.Logger }
-
-// NewListener creates new debug listener.
-func NewListener(logger *logrus.Logger) *listener {
- return &listener{logger}
+// Listener creates new debug listener.
+func Listener(logger *logrus.Logger) func(event int, ctx interface{}) {
+ return (&debugger{logger}).listener
}
-// Listener listens to http events and generates nice looking output.
-func (s *listener) Listener(event int, ctx interface{}) {
+// listener provide debug callback for system events. With colors!
+type debugger struct{ logger *logrus.Logger }
+
+// listener listens to http events and generates nice looking output.
+func (s *debugger) listener(event int, ctx interface{}) {
// http events
switch event {
case http.EventResponse:
log := ctx.(*http.Event)
- s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.Uri))
+ s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.URI))
case http.EventError:
log := ctx.(*http.Event)
if _, ok := log.Error.(roadrunner.JobError); ok {
- s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.Uri))
+ s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.URI))
} else {
s.logger.Info(utils.Sprintf(
"%s <white+hb>%s</reset> %s <red>%s</reset>",
statusColor(log.Status),
log.Method,
- log.Uri,
+ log.URI,
log.Error,
))
}
@@ -70,12 +70,6 @@ func (s *listener) Listener(event int, ctx interface{}) {
}
}
-// Serve serves.
-func (s *listener) Serve() error { return nil }
-
-// Stop stops the Listener.
-func (s *listener) Stop() {}
-
func statusColor(status int) string {
if status < 300 {
return utils.Sprintf("<green>%v</reset>", status)