@warn / @debug / @error
Diagnostics report from inside a rule; the selector is the condition. Nothing is written to the document.
Writing diagnostics
img:not([alt]) { @warn "img needs alt"; }
form button:not([type]) { @warn "button defaults to type=submit"; }
provider-fetch[is-error] { @error "fetch failed", prop("provision").error; }
todo-list {
$todos: prop("provision").body;
@debug "todos", $todos.length; /* again when $todos changes */
@on todo-remove { @debug "remove", event.detail.id; }
}img:not([alt]) { @warn "img needs alt"; }
form button:not([type]) { @warn "button defaults to type=submit"; }
provider-fetch[is-error] { @error "fetch failed", prop("provision").error; }
todo-list {
$todos: prop("provision").body;
@debug "todos", $todos.length; /* again when $todos changes */
@on todo-remove { @debug "remove", event.detail.id; }
}Each statement evaluates its expression on the matched element — bindings, attr(), prop(), event inside an @on block, module functions — and reports it. A comma list reports one value per item; a single expression is one value, even when it is a list.
When it speaks
@warnand@errorspeak once per element and rule. A warning repeated on every re-run is noise; a new offending element is its own warning. A run that resolves topreservesays nothing and does not count:@warn if(attr("data-bad"): "bad"; else: preserve);speaks oncedata-badis set.@debugspeaks on every application, so it re-logs when a binding orprop()it reads changes — a trace of the value over time.- A failing expression reports a
quark/error(like any declaration) instead of a diagnostic; under@warn/@error, once per element. - Outside a rule there is no element to evaluate against: a top-level statement is rejected when the sheet is built.
Where it goes
- The console, at the matching logger level:
Quark @warn (img:not([alt])): img needs alt. Published builds log errors only; raise the level in app code withimport { QuarkLogger } from "@excom/quark"(or@excom/nucleus-kit) andQuarkLogger.level = 2for@warn,3for@debug. - The DevTools hook, as
["quark", "diagnostic"]—level,values,message,expression, the selector, rule and element — so the Nucleus DevTools extension and the agent tools can list them next to the rule. SeeJS API .
Use @warn for invariants a sheet can state better than a test (img:not([alt]), button:not([type])), @error for States that should never occur, and @debug while developing a rule — then remove it. The log() and debug() built-ins remain for tracing inside an expression.