Diagnostic Output
log, warn, and error send a message to Otter's diagnostic output rather than to the program's normal output.
Otter
log "Server started."
warn "Connection is slow."
error "Could not connect."
This page is about the log / warn / error statements. It is not about the messages Otter itself prints when a program has a syntax or runtime error — every reference page shows what those look like for the statement it covers.
Diagnostics are not say
say is what a program tells the person using it. log, warn, and error are what it tells whoever is running or operating it — a developer watching a console, a log file, a monitoring tool. Otter keeps the two separate on purpose:
Otter
say "Welcome!"
log "Startup complete."
A host running Otter can send say output to a user interface while sending diagnostics somewhere else entirely, such as a log file or a monitoring service, without the program needing to know or care. They travel on separate channels.
Three levels
All three take the same kind of message as say — one or more values, joined with a space:
Otter
port is 8080
log "Listening on port" port
log records something that happened normally. warn flags something that is not wrong yet but is worth attention. error reports something that failed.
A realistic example
Otter
port is 8080
say "Otter web server"
log "Starting up."
log "Listening on port" port
warn "No configuration file found, using defaults."
error "Could not reach the database."
say "Ready."
Only the say lines are part of what the program is telling its user. The log, warn, and error lines went to the diagnostic channel.