passsy / loggingr4
Logging
PublicLog through package:chirp, or developer.log in a Flutter app without chirp, and never print(), because print loses the error and stack trace.
detector.tsisolate · reads files, writes none · no network · 100 ms · 32 MBEdit
import { mentioned, onPrompt, onWrite } from "@wellactually/sdk/v3";
import { calls, DART, isComment, isDartProject } from "dart-kit";
onPrompt({
*detect(event) {
if (isDartProject(event)) {
yield* mentioned(event, ["logger", "loggers", "logging", "chirp", "print", "prints"]);
}
},
});
// Only a print() the agent writes, the debugging reflex the rule exists
// for, not legacy prints in a file it merely opened. A call of its own:
// debugPrint( and logger.print( are something else.
onWrite({
globs: DART,
*detect(event) {
for (const written of event.written) {
// A comment is not code the agent wrote.
if (isComment(written.text)) {
continue;
}
if (calls(written.text, ["print"])) {
yield { line: written.line };
}
}
},
});
fixtures/dart_app/pubspec.yamlEdit
namedemo
environment
sdk^3.5.0
package.jsonEdit
{
"name": "logging",
"private": true,
"dependencies": {
"dart-kit": "*"
},
"tags": [
"dart",
"flutter"
]
}