hack some output. grab STDOUT damnit

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-24 08:30:40 -05:00
parent 597b17039a
commit e71d4f10ca
2 changed files with 24 additions and 8 deletions

View File

@ -23,6 +23,7 @@ import (
"runtime"
"runtime/pprof"
golog "log"
"fmt"
"time"
"reflect"
"github.com/davecgh/go-spew/spew"
@ -42,6 +43,8 @@ var debugToolkit bool = false // does spew stuff?
var Where string = "gui/log"
var externalLog func(...any)
type Spewt struct {
a bool
}
@ -126,6 +129,11 @@ func Log(a ...any) {
}
golog.Println(a...)
if (externalLog == nil) {
// golog.Println(a...)
} else {
externalLog(fmt.Sprint(a...))
}
}
func loggo() {
@ -147,3 +155,7 @@ func logindent(depth int, format string, a ...interface{}) {
func SetOutput(f *os.File) {
golog.SetOutput(f)
}
func SetToolkitOutput(newLog func(...any)) {
externalLog = newLog
}

View File

@ -19,6 +19,17 @@ var outputS []string
func log(a ...any) {
witlog.Where = "wit/gocui"
witlog.Log(a...)
}
func sleep(a ...any) {
witlog.Sleep(a...)
}
func exit(a ...any) {
witlog.Exit(a...)
}
func newLog(a ...any) {
s := fmt.Sprint(a...)
tmp := strings.Split(s, "\n")
outputS = append(outputS, tmp...)
@ -34,14 +45,7 @@ func log(a ...any) {
}
}
func sleep(a ...any) {
witlog.Sleep(a...)
}
func exit(a ...any) {
witlog.Exit(a...)
}
func setOutput(f *os.File) {
witlog.SetOutput(f)
witlog.SetToolkitOutput(newLog)
}