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.
tests, run by the registry7 passed · slowest 18.7 ms
- The advice links to wellactually.dev
✓fires13.4 ms
fires on a print() the agent writes
write lib/uploader.dartfired: line 2
Future<void> upload(Report report) async {
print('uploading report ${report.id}');
await client.put(report);
}✓quiet15.6 ms
stays quiet on a print() that was already there
write lib/uploader.dart · wrote line 3stayed quiet
Future<void> upload(Report report) async {
print('uploading report ${report.id}');
await client.put(report);
}✓skips0.0 ms
stays quiet when the agent only reads the file
read lib/uploader.dartno handler of the detector wants this event
Future<void> upload(Report report) async {
print('uploading report ${report.id}');
await client.put(report);
}✓quiet8.3 ms
stays quiet on chirp, debugPrint and print in comments
write lib/log.dartstayed quiet
// Never print() here.
void log(Object e, StackTrace stackTrace) {
chirp.error('failed', error: e, stackTrace: stackTrace);
debugPrint('done');
logger.print('x');
}✓fires18.7 ms
points at the principle when the user mentions logging
prompt · in fixtures/dart_appfired: "logging"
Add some logging to the upload path✓quiet5.6 ms
stays quiet on the same words outside a Dart project
promptstayed quiet
Add some logging to the upload path✓quiet15.7 ms
stays quiet on a prompt about something else
prompt · in fixtures/dart_appstayed quiet
Retry the upload twicedetector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, edit, prompt, read, source, write } from "@wellactually/sdk/v3/test";
const upload = source`
Future<void> upload(Report report) async {
print('uploading report \${report.id}');
await client.put(report);
}
`;
test("fires on a print() the agent writes", () => {
expect(detect(write("lib/uploader.dart", upload))).toEqual([{ line: 2 }]);
});
test("stays quiet on a print() that was already there", () => {
expect(detect(edit("lib/uploader.dart", upload, { written: " await client.put(report);" }))).toEqual([]);
});
test("stays quiet when the agent only reads the file", () => {
expect(detect(read("lib/uploader.dart", upload))).toEqual([]);
});
test("stays quiet on chirp, debugPrint and print in comments", () => {
const code = source`
// Never print() here.
void log(Object e, StackTrace stackTrace) {
chirp.error('failed', error: e, stackTrace: stackTrace);
debugPrint('done');
logger.print('x');
}
`;
expect(detect(write("lib/log.dart", code))).toEqual([]);
});
const dartApp = { project: "fixtures/dart_app" };
test("points at the principle when the user mentions logging", () => {
expect(detect(prompt("Add some logging to the upload path"), dartApp)).toEqual([{ match: "logging", depth: "pointer" }]);
});
test("stays quiet on the same words outside a Dart project", () => {
expect(detect(prompt("Add some logging to the upload path"))).toEqual([]);
});
test("stays quiet on a prompt about something else", () => {
expect(detect(prompt("Retry the upload twice"), dartApp)).toEqual([]);
});