refactor: route console.log calls in domain/search through logger#1870
refactor: route console.log calls in domain/search through logger#1870carlos-alm wants to merge 1 commit into
Conversation
generator.ts's embedding-progress messages now go through logger.info() (unconditionally visible, matches the info()-based "Reusing previously- stored embedding model" message already used in cli/commands/embed.ts) instead of console.log/stdout. semantic.ts's dimension-mismatch message is a genuine warning (same severity class as the file's existing warnOnSimilarQueries), so both of its console.log lines are merged into a single warn() call, following the fix already applied to prepare.ts. cli-formatter.ts is the actual data-output layer for `codegraph search` (including the --json contract), directly analogous to presentation/queries-cli/ — CLI display wrappers for query functions that already live in presentation/ and call console.log directly. No other domain/ file has precedent for presentation code living there, so it moves to presentation/search.ts rather than being kept as a domain-layer exception. Only two import sites needed updating (cli/commands/search.ts, the domain/search/index.ts barrel) plus one test import. docs check acknowledged: internal logging-layer refactor + file move, no new feature/language/CLI/architecture surface — README.md, CLAUDE.md, and ROADMAP.md do not need updates. Fixes #1754 Impact: 2 functions changed, 9 affected
Greptile SummaryThis PR routes
Confidence Score: 4/5Safe to merge — the changes are mechanical routing of console.log through the structured logger and a file rename with updated import paths. All three embed progress messages and the dimension-mismatch warning are now on stderr via the logger, which is correct for a CLI tool. The only notable side effect is the dropped leading newline before the "Stored embeddings" message, causing slightly different visual spacing in terminal output. Everything else is a clean rename with two call-site and one test import updated. src/domain/search/generator.ts — the dropped Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI["src/cli/commands/search.ts"] -->|imports search| PRES["src/presentation/search.ts\n(was: domain/search/search/cli-formatter.ts)"]
PRES -->|imports searchData / multiSearchData| SEM["src/domain/search/search/semantic.ts"]
PRES -->|imports ftsSearchData| KW["src/domain/search/search/keyword.ts"]
PRES -->|imports hybridSearchData| HYB["src/domain/search/search/hybrid.ts"]
PRES -->|imports warn| LOG["src/infrastructure/logger.ts"]
SEM -->|imports warn| LOG
GEN["src/domain/search/generator.ts\nbuildEmbeddings"] -->|imports info / warn| LOG
LOG -->|info / warn / error| STDERR["process.stderr"]
PRES -->|console.log for CLI output| STDOUT["process.stdout"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
CLI["src/cli/commands/search.ts"] -->|imports search| PRES["src/presentation/search.ts\n(was: domain/search/search/cli-formatter.ts)"]
PRES -->|imports searchData / multiSearchData| SEM["src/domain/search/search/semantic.ts"]
PRES -->|imports ftsSearchData| KW["src/domain/search/search/keyword.ts"]
PRES -->|imports hybridSearchData| HYB["src/domain/search/search/hybrid.ts"]
PRES -->|imports warn| LOG["src/infrastructure/logger.ts"]
SEM -->|imports warn| LOG
GEN["src/domain/search/generator.ts\nbuildEmbeddings"] -->|imports info / warn| LOG
LOG -->|info / warn / error| STDERR["process.stderr"]
PRES -->|console.log for CLI output| STDOUT["process.stdout"]
Reviews (1): Last reviewed commit: "refactor: route console.log calls in dom..." | Re-trigger Greptile |
| info( | ||
| `Stored ${vectors.length} embeddings (${dim}d, ${displayName}, strategy: ${strategy}) in graph.db`, | ||
| ); |
There was a problem hiding this comment.
The leading
that separated this final progress line from the previous output was dropped during the migration. The original console.log(' Stored ...') printed a blank line before the message; the new info(...) call omits it, so the three embed-progress lines now run together visually without the spacing the old output had.
| info( | |
| `Stored ${vectors.length} embeddings (${dim}d, ${displayName}, strategy: ${strategy}) in graph.db`, | |
| ); | |
| info( | |
| `\nStored ${vectors.length} embeddings (${dim}d, ${displayName}, strategy: ${strategy}) in graph.db`, | |
| ); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Codegraph Impact Analysis2 functions changed → 9 callers affected across 5 files
|
Summary
generator.ts(3 progress messages) andsemantic.ts(dimension-mismatch warning) calledconsole.logdirectly, violating this repo's domain→infrastructure logging convention. Routed throughlogger.info/logger.warnrespectively — confirmedlogger.info()writes unconditionally (not gated behindverbose), so no visibility regression.cli-formatter.tsmoved tosrc/presentation/search.ts(93%-similarity rename, mechanical — 2 call-site import updates + 1 test import). It's genuinely the CLI-output/--jsonrendering layer forcodegraph search, matching the establishedpresentation/queries-cli/pattern; verified no actual precedent exists for presentation-ish files living undersrc/domain/before ruling out leaving it in place.Closes #1754
Test plan
npm test— full suite green (3513 passed, 0 failed)npm run lint/npm run typecheck— cleancodegraph embedrun confirms all 3 progress messages print correctly; forced a dimension-mismatch to confirm the warning renders; rancodegraph searchto confirm the moved presentation module renders identical outputFiled #1869 for an out-of-scope finding discovered during manual verification:
findDbPath(viaembed's default DB resolution) ignores the positionaldirargument, unlikebuild.Stacked on #1868 (base branch
fix/issue-1753-points-to-max-iterations) — only the search/presentation/test diff is this issue's change.