[messages] add some logging to the worker#202
Conversation
🤖 Pull request artifacts
|
fdec9c1 to
c7d85f9
Compare
WalkthroughAdds a LogsService dependency to SendMessagesWorker and instruments the worker with DEBUG and ERROR LogEntry calls around start, completion, and exception handling; preserves the single call to messagesSvc.sendPendingMessages() and returns Result.success() or Result.retry(); no public API changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant WM as WorkManager
participant W as SendMessagesWorker
participant MS as MessagesService
participant LS as LogsService
WM->>W: startWork()
W->>LS: log(DEBUG: "Worker started")
W->>MS: sendPendingMessages()
alt success (no exception)
W->>LS: log(DEBUG: "Completed successfully")
W-->>WM: Result.success()
else exception
W->>LS: log(ERROR: "Failure: <err.message>")
W-->>WM: Result.retry()
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
app/src/main/java/me/capcom/smsgateway/modules/messages/workers/SendMessagesWorker.kt (3)
25-25: Prefer constructor/assisted injection for Worker (testability).Property injection works, but Koin’s Worker-friendly constructor/assisted injection improves testability and avoids static access patterns.
37-44: Tight loop: add cooperative cancellation and clarify the log; remove the confusing comment.Helps WorkManager stop gracefully and makes logs clearer.
Apply this diff:
- while (messagesSvc.sendPendingMessages()) { - // why not to `Result.retry()`? - logsService.insert( - LogEntry.Priority.DEBUG, - NAME, - "SendMessagesWorker started next iteration" - ) - } + while (messagesSvc.sendPendingMessages()) { + if (isStopped) break + logsService.insert( + LogEntry.Priority.DEBUG, + NAME, + "More pending messages detected; continuing" + ) + }
46-50: Success log nit.Consider INFO (if available) or include a small summary (e.g., iterations, counts) to make this log more actionable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
app/src/main/java/me/capcom/smsgateway/modules/messages/workers/SendMessagesWorker.kt(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build release / build-apk
- GitHub Check: Build insecure / build-apk
🔇 Additional comments (1)
app/src/main/java/me/capcom/smsgateway/modules/messages/workers/SendMessagesWorker.kt (1)
14-15: LGTM on logging imports.New LogsService/LogEntry imports look correct and align with the added usage.
d44224d to
1ba3dcf
Compare
|
On device... |
Summary by CodeRabbit