-
Notifications
You must be signed in to change notification settings - Fork 0
fix: consistent eprintln! lifecycle messages and scope filtered_urls in process.rs #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||
| use crate::crates::core::config::{Config, RenderMode}; | ||||||||||||
| use crate::crates::core::http::validate_url; | ||||||||||||
| use crate::crates::core::logging::{log_done, log_info, log_warn}; | ||||||||||||
| use crate::crates::core::logging::{log_info, log_warn}; | ||||||||||||
| use crate::crates::core::ui::{accent, muted, symbol_for_status}; | ||||||||||||
| use crate::crates::crawl::engine::{CrawlSummary, run_crawl_once, should_fallback_to_chrome}; | ||||||||||||
| use crate::crates::jobs::common::{JobTable, mark_job_completed, spawn_heartbeat_task}; | ||||||||||||
|
|
@@ -93,8 +93,17 @@ pub(super) async fn process_job( | |||||||||||
| .execute(pool) | ||||||||||||
| .await?; | ||||||||||||
| if is_canceled { | ||||||||||||
| log_info(&format!("worker canceled crawl job {id}")); | ||||||||||||
| eprintln!( | ||||||||||||
| "{} crawl job {} canceled", | ||||||||||||
| symbol_for_status("canceled"), | ||||||||||||
| muted(&id.to_string()), | ||||||||||||
| ); | ||||||||||||
| } else { | ||||||||||||
| eprintln!( | ||||||||||||
| "{} crawl job {} failed", | ||||||||||||
| symbol_for_status("failed"), | ||||||||||||
| muted(&id.to_string()), | ||||||||||||
| ); | ||||||||||||
|
Comment on lines
+102
to
+106
|
||||||||||||
| eprintln!( | |
| "{} crawl job {} failed", | |
| symbol_for_status("failed"), | |
| muted(&id.to_string()), | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use structured logger calls for lifecycle events, not eprintln!.
These new lifecycle messages bypass structured logging and log-level routing. In this worker module, emit canceled/cache-hit completion through log_info (and keep failures in log_warn) instead of eprintln!.
Proposed fix
if is_canceled {
- eprintln!(
- "{} crawl job {} canceled",
- symbol_for_status("canceled"),
- muted(&id.to_string()),
- );
+ log_info(&format!("crawl job {id} canceled"));
} else {
- eprintln!(
- "{} crawl job {} failed",
- symbol_for_status("failed"),
- muted(&id.to_string()),
- );
- log_warn(&format!("worker failed crawl job {id}"));
+ log_warn(&format!("worker failed crawl job {id}: {err}"));
}
@@
- eprintln!(
- "{} crawl job {} done (cache hit)",
- symbol_for_status("completed"),
- muted(&id.to_string()),
- );
+ log_info(&format!("crawl job {id} done (cache hit)"));As per coding guidelines, "Use structured log output via log_info and log_warn instead of println! in library code".
Also applies to: 247-251
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/jobs/crawl/runtime/worker/process.rs` around lines 96 - 106, Replace
the direct eprintln! lifecycle prints with structured logging: use log_info to
emit the "canceled" and cache-hit completion messages and keep failures using
log_warn; call log_info!(...) or log_warn!(...) with the same formatted message
using symbol_for_status(...) and muted(&id.to_string()) so the content remains
identical, and update the other eprintln! occurrences (the similar messages
later in the file) the same way; locate instances by searching for
eprintln!(..., symbol_for_status("canceled") / symbol_for_status("failed") and
replace accordingly.
Copilot
AI
Apr 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching the cache-hit completion from log_done to eprintln! means this completion event is no longer emitted through tracing (and therefore won’t appear in the JSON log file). If downstream monitoring/analytics relies on structured "done" events, consider keeping a tracing log (e.g., log_done/log_info) alongside the styled eprintln!.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change removes the
log_infocall for canceled jobs. Unlikeeprintln!,log_infois captured by tracing (including the JSON log file configured incrates/core/logging.rs). If cancellation events are important to retain in structured logs, consider keeping a tracing log for this path (in addition to or instead of the styledeprintln!).