diff --git a/yaml/parser.nim b/yaml/parser.nim index 86b19f8..c5527a1 100644 --- a/yaml/parser.nim +++ b/yaml/parser.nim @@ -125,11 +125,6 @@ proc afterPairValue(c: Context, e: var Event): bool proc emitCached(c: Context, e: var Event): bool {.pop.} -template debug(message: string) {.dirty.} = - when defined(yamlDebug): - try: styledWriteLine(stdout, fgBlue, message) - except ValueError, IOError: discard - template pushLevel(c: Context, newState: State, newIndent: int) = debug("parser: push " & newState.astToStr & ", indent = " & $newIndent) c.levels.add(Level(state: newState, indentation: newIndent)) diff --git a/yaml/private/lex.nim b/yaml/private/lex.nim index e743a07..a204a8c 100644 --- a/yaml/private/lex.nim +++ b/yaml/private/lex.nim @@ -167,10 +167,13 @@ proc streamEnd(lex: var Lexer): bool {.raises: [].} # helpers -template debug(message: string) {.dirty.} = +template debug*(message: string) = when defined(yamlDebug): - try: styledWriteLine(stdout, fgBlue, message) - except ValueError, IOError: discard + when nimvm: + echo "yamlDebug: ", message + else: + try: styledWriteLine(stdout, fgBlue, message) + except ValueError, IOError: discard proc generateError(lex: Lexer, message: string): ref LexerError {.raises: [].} =