diff options
| author | Bobby <[email protected]> | 2023-11-17 19:45:44 +0000 |
|---|---|---|
| committer | Bobby <[email protected]> | 2023-11-17 19:45:44 +0000 |
| commit | 066ab9ccf3b1d161f91ba1f50599ca33b1708d62 (patch) | |
| tree | c2e6ad47a5d0479dcd8504b26606d85d7171b80e /parser/parser_tracing.go | |
| parent | 4d4840e1c286eb06c474b32435b5ae62b47e8192 (diff) | |
| download | mana-066ab9ccf3b1d161f91ba1f50599ca33b1708d62.tar.xz mana-066ab9ccf3b1d161f91ba1f50599ca33b1708d62.zip | |
added:parser tracing for verbose testing
Diffstat (limited to 'parser/parser_tracing.go')
| -rw-r--r-- | parser/parser_tracing.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/parser/parser_tracing.go b/parser/parser_tracing.go new file mode 100644 index 0000000..a0819da --- /dev/null +++ b/parser/parser_tracing.go @@ -0,0 +1,37 @@ +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() +}
\ No newline at end of file |
