diff options
| author | Jeff Carr <[email protected]> | 2025-10-28 22:26:32 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-28 22:26:32 -0500 |
| commit | d1c6c000ccedf21e356ee30411b861b544313e18 (patch) | |
| tree | 753ad517e06cea3e16b6ea2fcdc2794075915456 /argv.Print.go | |
| parent | 816758895ca1244c967817565b5d9895857e1cbb (diff) | |
remove panic's
Diffstat (limited to 'argv.Print.go')
| -rw-r--r-- | argv.Print.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/argv.Print.go b/argv.Print.go index 68c2391..a35d380 100644 --- a/argv.Print.go +++ b/argv.Print.go @@ -9,6 +9,7 @@ import ( "strings" "go.wit.com/lib/cobol" + "go.wit.com/lib/config" ) func (pb *Argv) Debugf(fmts string, parts ...any) { @@ -67,9 +68,28 @@ func PrintStddbg() { if !me.debug { return } + if config.Exists("/tmp/argv.debug") { + PrintStddbgFile() + return + } + lines := strings.Split(strings.TrimSpace(PB.Stddbg), "\n") + if len(lines) == 0 { + return + } + fmt.Fprintf(os.Stderr, "\n") + for _, line := range lines { + fmt.Fprintf(os.Stderr, "%s\n", line) + } + fmt.Fprintf(os.Stderr, "\n") +} + +func PrintStddbgFile() { + if !me.debug { + return + } f, err := os.OpenFile("/tmp/argv.debug", os.O_APPEND|os.O_RDWR|os.O_CREATE, 0644) if err != nil { - panic("WTF openfile") + return } defer f.Close() lines := strings.Split(strings.TrimSpace(PB.Stddbg), "\n") |
