From 775c7e67eadde09875fd5a725339433df28b6ffa Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 11 Nov 2016 09:48:01 +0000 Subject: [PATCH] ability to enable broker debugging --- drone/server.go | 5 +++++ router/middleware/broker.go | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drone/server.go b/drone/server.go index 465595ce..07b233a2 100644 --- a/drone/server.go +++ b/drone/server.go @@ -26,6 +26,11 @@ var serverCmd = cli.Command{ Name: "debug", Usage: "start the server in debug mode", }, + cli.BoolFlag{ + EnvVar: "DRONE_BROKER_DEBUG", + Name: "broker-debug", + Usage: "start the broker in debug mode", + }, cli.StringFlag{ EnvVar: "DRONE_SERVER_ADDR", Name: "server-addr", diff --git a/router/middleware/broker.go b/router/middleware/broker.go index 2222df51..41b7d509 100644 --- a/router/middleware/broker.go +++ b/router/middleware/broker.go @@ -1,16 +1,19 @@ package middleware import ( + "os" "sync" handlers "github.com/drone/drone/server" "github.com/codegangsta/cli" + "github.com/drone/mq/logger" "github.com/drone/mq/server" "github.com/drone/mq/stomp" "github.com/Sirupsen/logrus" "github.com/gin-gonic/gin" + "github.com/tidwall/redlog" ) const ( @@ -23,7 +26,15 @@ const ( func Broker(cli *cli.Context) gin.HandlerFunc { secret := cli.String("agent-secret") if secret == "" { - logrus.Fatalf("failed to generate token from DRONE_SECRET") + logrus.Fatalf("fatal error. please provide the DRONE_SECRET") + } + + // setup broker logging. + log := redlog.New(os.Stderr) + log.SetLevel(0) + logger.SetLogger(log) + if cli.Bool("broker-debug") { + log.SetLevel(1) } broker := server.NewServer(