Need help?
Ask a question or report a problem on GitHub.
Open an issue
Logging and debugging
Write diagnostic output that is separate from what your program says.
Logging
Application logging should be distinct from ordinary user output.
Otter
log "Server started."
Warnings:
Otter
warn "Connection is slow."
Errors:
Otter
error "Could not connect."
log, warn, and error should represent diagnostic output rather than normal application-facing output.
Debugging
Otter 1.0 has no debug statement. To see a value while a program runs, log it:
Otter
user has name "Ada", age 36 log "user:" name of user age of user
To look inside Otter itself, otter run accepts developer flags:
Terminal
otter run app.ot -DebugTokens otter run app.ot -DebugAst otter run app.ot -DebugErrors
What they show:
- -DebugTokens: the tokens the lexer produced, before the program runs
- -DebugAst: the syntax tree the parser produced, before the program runs
- -DebugErrors: where the problem is inside Otter, when Otter reports a bug in itself
Without -DebugErrors, errors are shown as readable Otter messages that name the line, never as raw PowerShell stack traces.