mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
logging: re-level, redact user data at info, and key links by post id
P0 — level rework + redaction: - info now carries only lifecycle, per-post business results (sent / forwarded / copied / template applied), admin actions and anomalies (upload fallback, retry enqueue; dead-letter stays error). - Per-request detail moved to debug: message/command logging, URL extraction, fetching/fetched, link-cache hits, media-group batch sends, queue processing (enqueue/processing/completed/rescheduled), photo processing (downscale/transcode), inline queries, sensitive-tweet note. - Full user-submitted URLs and message text now appear only at debug; at info and above links are printed via the normalized cache key. P1 — request correlation: - handlers::log_key() maps a URL to its normalized post key (twitter:<id> / pixiv:<id> / bsky:<handle>/<rkey>). The whole lifecycle of one link (fetch -> send -> cache -> fallback) now logs [key=...], so multi-worker logs can be correlated by grepping the key. Convention documented in AGENTS.md.
This commit is contained in:
@@ -188,7 +188,7 @@ impl PersistentTaskQueue {
|
||||
self.counter.fetch_add(1, Ordering::Relaxed)
|
||||
);
|
||||
let payload = payload.to_string();
|
||||
log::info!("enqueued {id} (run_after {run_after:.1})");
|
||||
log::debug!("enqueued {id} (run_after {run_after:.1})");
|
||||
self.pool.with_conn(move |conn| {
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO tasks (id, payload, run_after, attempts, status, locked_until, created_at) \
|
||||
@@ -339,10 +339,10 @@ impl QueueWorker {
|
||||
return;
|
||||
}
|
||||
};
|
||||
log::info!("processing {} (attempt {})", row.id, row.attempts + 1);
|
||||
log::debug!("processing {} (attempt {})", row.id, row.attempts + 1);
|
||||
match (self.handler)(payload).await {
|
||||
Ok(()) => {
|
||||
log::info!("task {} completed", row.id);
|
||||
log::debug!("task {} completed", row.id);
|
||||
self.delete_row(&row.id).await;
|
||||
}
|
||||
Err(QueueError::Retryable {
|
||||
@@ -356,7 +356,7 @@ impl QueueWorker {
|
||||
(self.dead_letter)(payload, message).await;
|
||||
} else {
|
||||
let delay = scaled_retry_delay(delay_seconds, row.attempts);
|
||||
log::info!(
|
||||
log::debug!(
|
||||
"task {} rescheduled in {delay:.1}s (attempt {})",
|
||||
row.id,
|
||||
row.attempts + 1
|
||||
|
||||
Reference in New Issue
Block a user