@@ -3,7 +3,9 @@ package gnolang
3
3
import (
4
4
"fmt"
5
5
"io"
6
+ "path"
6
7
"reflect"
8
+ "runtime"
7
9
"slices"
8
10
"strconv"
9
11
"strings"
@@ -2120,17 +2122,23 @@ func (m *Machine) Panic(ex TypedValue) {
2120
2122
func (m * Machine ) Println (args ... interface {}) {
2121
2123
if debug {
2122
2124
if enabled {
2123
- s := strings .Repeat ("|" , m .NumOps )
2124
- debug .Println (append ([]interface {}{s }, args ... )... )
2125
+ _ , file , line , _ := runtime .Caller (2 ) // get caller info
2126
+ caller := fmt .Sprintf ("%-.12s:%-4d" , path .Base (file ), line )
2127
+ prefix := fmt .Sprintf ("DEBUG: %17s: " , caller )
2128
+ s := prefix + strings .Repeat ("|" , m .NumOps )
2129
+ fmt .Println (append ([]interface {}{s }, args ... )... )
2125
2130
}
2126
2131
}
2127
2132
}
2128
2133
2129
2134
func (m * Machine ) Printf (format string , args ... interface {}) {
2130
2135
if debug {
2131
2136
if enabled {
2132
- s := strings .Repeat ("|" , m .NumOps )
2133
- debug .Printf (s + " " + format , args ... )
2137
+ _ , file , line , _ := runtime .Caller (2 ) // get caller info
2138
+ caller := fmt .Sprintf ("%-.12s:%-4d" , path .Base (file ), line )
2139
+ prefix := fmt .Sprintf ("DEBUG: %17s: " , caller )
2140
+ s := prefix + strings .Repeat ("|" , m .NumOps )
2141
+ fmt .Printf (s + " " + format , args ... )
2134
2142
}
2135
2143
}
2136
2144
}
0 commit comments