Skip to content

Commit 839404f

Browse files
authored
fix: format crumb data on same line as message (#17)
## Summary - Data was printed on a separate line from the message, making log output noisy and harder to scan - Now prints inline: `webapp:llm-pricing loaded models from db +353ms { count: 145 }` - Set `breakLength: Infinity` on `util.inspect` to prevent Node from wrapping the data object - Fixed in both `ConsoleSink` (stderr output) and `formatCrumbPretty` (CLI tail/query output) ## Test plan - [ ] `pnpm build` passes - [ ] Run a service with `AGENTCRUMBS=1` and verify crumbs print on a single line - [ ] `agentcrumbs tail` and `agentcrumbs query` also show single-line output
2 parents 8b2317e + e7ca8bf commit 839404f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.changeset/single-line-output.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"agentcrumbs": patch
3+
---
4+
5+
Format crumb data on the same line as the message instead of a separate line

packages/agentcrumbs/src/cli/format.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function formatDelta(dt: number): string {
1010

1111
function formatData(data: unknown): string {
1212
if (data === undefined || data === null) return "";
13-
return inspect(data, { colors: true, compact: true, depth: 4, breakLength: 100 });
13+
return inspect(data, { colors: true, compact: true, depth: 4, breakLength: Infinity });
1414
}
1515

1616
export function formatCrumbPretty(crumb: Crumb): string {
@@ -61,7 +61,7 @@ export function formatCrumbPretty(crumb: Crumb): string {
6161

6262
const dataStr = formatData(crumb.data);
6363
if (dataStr) {
64-
line += `\n${" ".repeat(depth)} ${dataStr}`;
64+
line += ` ${dataStr}`;
6565
}
6666

6767
return line;

packages/agentcrumbs/src/sinks/console.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function formatDelta(dt: number): string {
1010

1111
function formatData(data: unknown): string {
1212
if (data === undefined || data === null) return "";
13-
return inspect(data, { colors: true, compact: true, depth: 4, breakLength: 120 });
13+
return inspect(data, { colors: true, compact: true, depth: 4, breakLength: Infinity });
1414
}
1515

1616
function indent(depth: number): string {
@@ -62,7 +62,7 @@ export class ConsoleSink implements Sink {
6262

6363
const dataStr = formatData(crumb.data);
6464
if (dataStr) {
65-
line += `\n${pad} ${dataStr}`;
65+
line += ` ${dataStr}`;
6666
}
6767

6868
process.stderr.write(line + "\n");

0 commit comments

Comments
 (0)