Skip to content

feat: add xbot-log CLI for remote log messages#28

Merged
ClemensElflein merged 1 commit into
mainfrom
feat/log-receiver
May 26, 2026
Merged

feat: add xbot-log CLI for remote log messages#28
ClemensElflein merged 1 commit into
mainfrom
feat/log-receiver

Conversation

@ClemensElflein
Copy link
Copy Markdown
Member

@ClemensElflein ClemensElflein commented May 26, 2026

Summary

  • Adds xbot_service_interface/log_receiver.py — subscribes to the xBot LOG multicast channel and prints coloured output (timestamp, level, source IP, message)
  • Registers xbot-log as a console script entry point in pyproject.toml
  • Supports --bind, --level (trace/debug/info/warning/error/critical), --no-colour flags

Test plan

  • xbot-log starts and listens on the multicast group
  • Log messages from a running service appear with correct level colours
  • --no-colour disables ANSI output (auto-detected when stdout is not a tty)
  • --level warning suppresses debug/info messages

Subscribes to the LOG multicast channel and prints coloured output
with timestamp, level tag, source IP and message text.

Registered as the xbot-log console script entry point.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

Adds a UDP multicast log receiver module (log_receiver.py) that captures xBot log messages from a configured multicast group, filters by severity level, applies ANSI color formatting, and displays timestamped output via a xbot-log CLI command. The CLI supports binding to a specific interface, setting minimum log level, and toggling colors.

Changes

Log Receiver and CLI Tool

Layer / File(s) Summary
Color formatting and severity mapping
xbot_service_interface_py/xbot_service_interface/log_receiver.py
ANSI color palette indexed by LogLevel and _colour() helper function map numeric severity to color codes and short severity tag labels.
UDP multicast socket creation
xbot_service_interface_py/xbot_service_interface/log_receiver.py
_make_socket() creates a UDP socket, enables socket reuse options, binds to the local multicast address, and joins the multicast group using LOG_MULTICAST_ADDR and MULTICAST_PORT with interface selection based on bind_ip.
Message reception and processing loop
xbot_service_interface_py/xbot_service_interface/log_receiver.py
_recv_loop() continuously reads UDP datagrams, validates message size and type, unpacks header to extract log severity, filters messages below minimum level, decodes payload as UTF-8 (with fallback to raw bytes), formats timestamps, and prints colored or plain output; exits on socket errors.
CLI argument parsing and main entry point
xbot_service_interface_py/xbot_service_interface/log_receiver.py
main() parses command-line arguments for multicast bind IP (--bind), minimum log level (--level), and color disabling (--no-colour/--no-color); determines whether to suppress colors based on stdout TTY state; starts the receive loop; handles KeyboardInterrupt gracefully; and ensures socket closure in a finally block.
Console script registration
xbot_service_interface_py/pyproject.toml
Project metadata adds xbot-log console script entry point mapping to xbot_service_interface.log_receiver:main.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A new receiver hops in place,
Multicast logs at a brisk pace!
Colors dance and timestamps glow,
CLI flags direct the flow—
xbot-log now leads the way! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: add xbot-log CLI for remote log messages' clearly and concisely describes the main change: adding a new CLI tool for receiving and displaying remote xBot log messages.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/log-receiver

Comment @coderabbitai help to get the list of available commands and usage tips.

@ClemensElflein ClemensElflein merged commit 085b329 into main May 26, 2026
12 of 13 checks passed
@ClemensElflein ClemensElflein deleted the feat/log-receiver branch May 26, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant