aboutsummaryrefslogtreecommitdiff
path: root/parser/parser_tracing.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-05-20 16:27:23 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-05-20 16:27:23 +0200
commitce78935009d931faf2db7e882929a7a4c95ce3e0 (patch)
tree47054996395b6e23b668f8c94cdb800bb308d79d /parser/parser_tracing.go
parent562c190b394b0ad76d4d591be74e2f37513c964a (diff)
02
Diffstat (limited to 'parser/parser_tracing.go')
-rw-r--r--parser/parser_tracing.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/parser/parser_tracing.go b/parser/parser_tracing.go
new file mode 100644
index 0000000..5fc569b
--- /dev/null
+++ b/parser/parser_tracing.go
@@ -0,0 +1,32 @@
+package parser
+
+import (
+ "fmt"
+ "strings"
+)
+
+var traceLevel int = 0
+
+const traceIdentPlaceholder string = "\t"
+
+func identLevel() string {
+ return strings.Repeat(traceIdentPlaceholder, traceLevel-1)
+}
+
+func tracePrint(fs string) {
+ fmt.Printf("%s%s\n", identLevel(), fs)
+}
+
+func incIdent() { traceLevel = traceLevel + 1 }
+func decIdent() { traceLevel = traceLevel - 1 }
+
+func trace(msg string) string {
+ incIdent()
+ tracePrint("BEGIN " + msg)
+ return msg
+}
+
+func untrace(msg string) {
+ tracePrint("END " + msg)
+ decIdent()
+}