From 12ab3b54a643bfef164b16fbdb1b59d6fe0997d2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 13 May 2019 09:05:03 -0700 Subject: [PATCH] remove debugging stuff Signed-off-by: Jeff Carr --- Makefile | 4 ++ config.go | 15 ++++++ infoTabUI.go | 142 ++++++++++++++++++++++++++++----------------------- 3 files changed, 96 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index 0b078f6..d1b8718 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,10 @@ run: go build ./cloud-control-panel +debug: + go build + ./cloud-control-panel --debugging + nogui: go build ./cloud-control-panel -nogui diff --git a/config.go b/config.go index 6f6bee8..29f437a 100644 --- a/config.go +++ b/config.go @@ -34,6 +34,7 @@ var customUsage = func() { func parseFlags() { var version string var nogui bool + var debugging bool var hostname string var width int var height int @@ -45,6 +46,7 @@ func parseFlags() { flag.IntVar (&height, "height", 600, "Height of the Window") flag.BoolVar (&nogui, "nogui", nogui, "Do not display the GUI") + flag.BoolVar (&debugging, "debugging", debugging, "Enable debugging") // Set the output if something fails to stdout rather than stderr flag.CommandLine.SetOutput(os.Stdout) @@ -58,10 +60,17 @@ func parseFlags() { log.Println("flag.Parse() failed") } + if (debugging == true) { + log.Println("ENABLE DEBUG", debugging) + } else { + log.Println("DISABLE DEBUG", debugging) + } + config.Set("width", width) config.Set("height", height) config.Set("hostname", hostname) config.Set("nogui", nogui) + config.Set("debugging", debugging) } func parseConfig() { @@ -97,4 +106,10 @@ func parseConfig() { if (config.String("nogui") == "true") { log.Println("DO NOT DISPLAY THE GUI") } + + if (config.String("debugging") == "true") { + log.Println("ENABLE DEBUG", config.String("debugging")) + } else { + log.Println("DISABLE DEBUG", config.String("debugging")) + } } diff --git a/infoTabUI.go b/infoTabUI.go index 3defa2f..a75a1eb 100644 --- a/infoTabUI.go +++ b/infoTabUI.go @@ -37,73 +37,15 @@ func makeCloudInfoBox() ui.Control { }) vbox.Append(addXbutton, false) - vbox.Append(ui.NewLabel("Debugging:"), false) - - // ATTEMPT TO ADD THE TABLE HERE - add2button := ui.NewButton("Add a Test Table") - add2button.OnClicked(func(*ui.Button) { - log.Println("send over socket") - addTableTab() + addButton := ui.NewButton("Add Account") + addButton.OnClicked(func(*ui.Button) { + log.Println("Not Implemented Yet. Try adding --debugging") }) - vbox.Append(add2button, false) - // ATTEMPT TO ADD THE TABLE HERE END + vbox.Append(addButton, false) - hbox.Append(ui.NewVerticalSeparator(), false) - - // Send a test protobuf Event to localhost - add3button := ui.NewButton("Add buf to chann") - add3button.OnClicked(func(*ui.Button) { - log.Println("add protobuf event to the channel") - addSampleEvent() - }) - vbox.Append(add3button, false) - - add4button := ui.NewButton("Add Demo Event") - add4button.OnClicked(func(*ui.Button) { - log.Println("add demo protobuf event to the channel") - msg := pb.CreateSampleEvent() - msg.Name = "generated in addSampleEvent()" - msg.Type = pb.Event_DEMO - addEvent(msg) - }) - vbox.Append(add4button, false) - - add4abutton := ui.NewButton("Close Demo GUI") - add4abutton.OnClicked(func(*ui.Button) { - gui.CloseDemoUI() - }) - vbox.Append(add4abutton, false) - - // Send a protobuf Event over the WIT socket - add5button := ui.NewButton("Send protobuf to localhost") - add5button.OnClicked(func(*ui.Button) { - log.Println("sent a Marshal'd protobuf to a localhost socket") - sendDataToDest() - }) - vbox.Append(add5button, false) - - // Send a protobuf over a gorilla websocket - add6button := ui.NewButton("gorillaSendProtobuf()") - add6button.OnClicked(func(*ui.Button) { - log.Println("gorillaSendProtobuf()") - gorillaSendProtobuf() - }) - vbox.Append(add6button, false) - - // debug all the golang goroutines - add7button := ui.NewButton("debug.PrintStack()") - add7button.OnClicked(func(*ui.Button) { - log.Println("debug.PrintStack() (SHOULD BE JUST THIS goroutine)") - debug.PrintStack() - - log.Println("ATTEMPT FULL STACK DUMP") - log.Println("ATTEMPT FULL STACK DUMP") - log.Println("ATTEMPT FULL STACK DUMP") - buf := make([]byte, 1<<16) - runtime.Stack(buf, true) - fmt.Printf("%s", buf) - }) - vbox.Append(add7button, false) + if (config.String("debugging") == "true") { + addDebuggingButtons(vbox) + } hbox.Append(ui.NewVerticalSeparator(), false) @@ -230,3 +172,73 @@ func addVmsTab(count int) *gui.TableData { mh := gui.AddTableTab(cloudtab, 1, "Virtual Machines", count, parts) return mh } + +func addDebuggingButtons(vbox *ui.Box) { + vbox.Append(ui.NewLabel("Debugging:"), false) + + // ATTEMPT TO ADD THE TABLE HERE + add2button := ui.NewButton("Add a Test Table") + add2button.OnClicked(func(*ui.Button) { + log.Println("send over socket") + addTableTab() + }) + vbox.Append(add2button, false) + // ATTEMPT TO ADD THE TABLE HERE END + + // hbox.Append(ui.NewVerticalSeparator(), false) + + // Send a test protobuf Event to localhost + add3button := ui.NewButton("Add buf to chann") + add3button.OnClicked(func(*ui.Button) { + log.Println("add protobuf event to the channel") + addSampleEvent() + }) + vbox.Append(add3button, false) + + add4button := ui.NewButton("Add Demo Event") + add4button.OnClicked(func(*ui.Button) { + log.Println("add demo protobuf event to the channel") + msg := pb.CreateSampleEvent() + msg.Name = "generated in addSampleEvent()" + msg.Type = pb.Event_DEMO + addEvent(msg) + }) + vbox.Append(add4button, false) + + add4abutton := ui.NewButton("Close Demo GUI") + add4abutton.OnClicked(func(*ui.Button) { + gui.CloseDemoUI() + }) + vbox.Append(add4abutton, false) + + // Send a protobuf Event over the WIT socket + add5button := ui.NewButton("Send protobuf to localhost") + add5button.OnClicked(func(*ui.Button) { + log.Println("sent a Marshal'd protobuf to a localhost socket") + sendDataToDest() + }) + vbox.Append(add5button, false) + + // Send a protobuf over a gorilla websocket + add6button := ui.NewButton("gorillaSendProtobuf()") + add6button.OnClicked(func(*ui.Button) { + log.Println("gorillaSendProtobuf()") + gorillaSendProtobuf() + }) + vbox.Append(add6button, false) + + // debug all the golang goroutines + add7button := ui.NewButton("debug.PrintStack()") + add7button.OnClicked(func(*ui.Button) { + log.Println("debug.PrintStack() (SHOULD BE JUST THIS goroutine)") + debug.PrintStack() + + log.Println("ATTEMPT FULL STACK DUMP") + log.Println("ATTEMPT FULL STACK DUMP") + log.Println("ATTEMPT FULL STACK DUMP") + buf := make([]byte, 1<<16) + runtime.Stack(buf, true) + fmt.Printf("%s", buf) + }) + vbox.Append(add7button, false) +}