use standard debugger.go

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-12 10:14:50 -06:00
parent 0949113167
commit bc01313a04
4 changed files with 33 additions and 57 deletions

View File

@ -8,14 +8,11 @@ nocui: build
gocui: build gocui: build
reset reset
./gadgetwindow --gui gocui >/tmp/gadgetwindow.stderr 2>&1 echo "redirecting STDOUT & STDERR to /tmp/gadgetwindow.out"
# ./gadgetwindow --gui gocui --tmp-log ./gadgetwindow --gui gocui >/tmp/gadgetwindow.out 2>&1
log: log:
tail -f /tmp/guilogfile /tmp/witgui.* /tmp/gadget* tail -f /tmp/gadgetwindow.out*
test-tmp-log: build
./gadgetwindow --gui andlabs --tmp-log
debugger: build debugger: build
reset reset
@ -23,22 +20,15 @@ debugger: build
build: build:
ifeq ($(GO111MODULE),) ifeq ($(GO111MODULE),)
echo no. you must use GO111MODULE here @echo
false @echo In GO, to build here you must export GO111MODULE=off
@echo
@false
else else
-rm -f gadgetwindow -rm -f gadgetwindow
go build -v -x go build -v -x
endif endif
stderr: build
echo "writing to /tmp/gadgetwindow.stderr"
./gadgetwindow >/tmp/gadgetwindow.stderr 2>&1
push:
git add --all
git commit -a
git push
goimports: goimports:
goimports -w *.go goimports -w *.go
@ -47,4 +37,3 @@ redomod:
goimports -w *.go goimports -w *.go
GO111MODULE= go mod init GO111MODULE= go mod init
GO111MODULE= go mod tidy GO111MODULE= go mod tidy

27
args.go
View File

@ -1,27 +0,0 @@
package main
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
var args struct {
TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
}
func init() {
arg.MustParse(&args)
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
} else {
log.Info("cmd line --debugger == false")
}
}

26
debugger.go Normal file
View File

@ -0,0 +1,26 @@
package main
/*
enables GUI options and the debugger in your application
*/
import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
var args struct {
}
func init() {
arg.MustParse(&args)
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
}

12
main.go
View File

@ -27,24 +27,12 @@ func main() {
log.SetAll(true) log.SetAll(true)
log.ShowFlags() log.ShowFlags()
} }
if args.TmpLog {
// send all log() output to a file in /tmp
log.SetTmp()
}
myGui = gui.New() myGui = gui.New()
myGui.Default() myGui.Default()
helloworld() helloworld()
basicWindow = makebasicWindow() basicWindow = makebasicWindow()
// run the debugger if triggered from the commandline
if debugger.ArgDebug() {
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
// go will sit here until the window exits // go will sit here until the window exits
gui.Watchdog() gui.Watchdog()
} }