From 00b5b83dcff4904aeb18760caa193fa3393241e0 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Fri, 9 Mar 2018 17:33:18 +0100 Subject: Fixed terminal output (support escape and control characters) Signed-off-by: Sebastien Douheret --- main.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index a6f8104..2dfd056 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,6 @@ import ( "github.com/Sirupsen/logrus" "github.com/joho/godotenv" - socketio_client "github.com/sebd71/go-socket.io-client" "github.com/urfave/cli" ) @@ -71,8 +70,8 @@ var EnvConfFileMap map[string]string // HTTPCli Global variable that hold HTTP Client var HTTPCli *common.HTTPClient -// IOsk Global variable that hold SocketIo client -var IOsk *socketio_client.Client +// IOSkClient Global variable that hold SocketIo client +var IOSkClient *IOSockClient // exitError exists this program with the specified error func exitError(code int, f string, a ...interface{}) { @@ -96,6 +95,14 @@ func earlyDisplay() { earlyDebug = []string{} } +// LogSillyf Logging helper used for silly logging (printed on log.debug) +func LogSillyf(format string, args ...interface{}) { + sillyVal, sillyLog := os.LookupEnv("XDS_LOG_SILLY") + if sillyLog && sillyVal == "1" { + Log.Debugf("SILLY: "+format, args...) + } +} + // main func main() { @@ -382,23 +389,17 @@ func XdsConnInit(ctx *cli.Context) error { // Create io Websocket client Log.Debugln("Connecting IO.socket client on ", agentURL) - opts := &socketio_client.Options{ - Transport: "websocket", - Header: make(map[string][]string), - } - opts.Header["XDS-AGENT-SID"] = []string{HTTPCli.GetClientID()} - - IOsk, err = socketio_client.NewClient(agentURL, opts) + IOSkClient, err = NewIoSocketClient(agentURL, HTTPCli.GetClientID()) if err != nil { - return cli.NewExitError("IO.socket connection error: "+err.Error(), 1) + return cli.NewExitError(err.Error(), 1) } - IOsk.On("error", func(err error) { + IOSkClient.On("error", func(err error) { fmt.Println("ERROR Websocket: ", err.Error()) }) ctx.App.Metadata["httpCli"] = HTTPCli - ctx.App.Metadata["ioskCli"] = IOsk + ctx.App.Metadata["ioskCli"] = IOSkClient // Display version in logs (debug helpers) ver := xaapiv1.XDSVersion{} -- cgit 1.2.3-korg