Skip to content

Backports/1.4/add logs to mavlink server #3467

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

Conversation

joaoantoniocardoso
Copy link
Member

@joaoantoniocardoso joaoantoniocardoso commented Aug 8, 2025

This is a backport of #3340 and #3342 into 1.4

Summary by Sourcery

New Features:

  • Initialize a log_path attribute in MAVLinkServer and include a --log-path argument with a default path when constructing the server command.

Copy link

sourcery-ai bot commented Aug 8, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR backports logging support to the MAVLink server by adding a configurable log_path attribute, assigning a default directory, and including it as a --log-path flag in the server command.

Class diagram for updated MAVLinkServer logging support

classDiagram
    class MAVLinkServer {
        +Optional[str] log_path
        +__init__()
        +_get_version() Optional[str]
        +command() str
        +name() str
    }
    MAVLinkServer --|> AbstractRouter
Loading

File-Level Changes

Change Details Files
Introduce log path configuration for MAVLinkServer
  • Initialize self.log_path in constructor
  • Assign default log path when unset
  • Append --log-path argument to server invocation
core/services/ardupilot_manager/mavlink_proxy/MAVLinkServer.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @joaoantoniocardoso - I've reviewed your changes - here's some feedback:

  • Consider moving the default log_path initialization into init (or accepting it as a constructor parameter) so you avoid the lazy check inside convert_endpoint.
  • Rather than hardcoding "/var/logs/blueos/services/mavlink-server/", make the log directory configurable via a setting or environment variable to improve flexibility.
  • Add a check to create or validate the log_path directory before launching the server to prevent runtime failures if the path doesn’t exist.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving the default log_path initialization into __init__ (or accepting it as a constructor parameter) so you avoid the lazy check inside convert_endpoint.
- Rather than hardcoding "/var/logs/blueos/services/mavlink-server/", make the log directory configurable via a setting or environment variable to improve flexibility.
- Add a check to create or validate the log_path directory before launching the server to prevent runtime failures if the path doesn’t exist.

## Individual Comments

### Comment 1
<location> `core/services/ardupilot_manager/mavlink_proxy/MAVLinkServer.py:44` </location>
<code_context>
         endpoints = " ".join([convert_endpoint(endpoint) for endpoint in [master_endpoint, *filtered_endpoints]])

-        return f"{self.binary()} {endpoints}"
+        if not self.log_path:
+            self.log_path = "/var/logs/blueos/services/mavlink-server/"
+
+        return f"{self.binary()} {endpoints} --log-path={self.log_path}"
</code_context>

<issue_to_address>
Using a mutable default path assignment in get_command() may cause issues if log_path is intentionally set to an empty string.

Checking 'if not self.log_path' will override valid empty string values. Use 'if self.log_path is None' to distinguish between unset and intentionally empty log_path.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +44 to +45
if not self.log_path:
self.log_path = "/var/logs/blueos/services/mavlink-server/"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Using a mutable default path assignment in get_command() may cause issues if log_path is intentionally set to an empty string.

Checking 'if not self.log_path' will override valid empty string values. Use 'if self.log_path is None' to distinguish between unset and intentionally empty log_path.

@patrickelectric patrickelectric merged commit 5ce55ae into bluerobotics:1.4 Aug 9, 2025
6 checks passed
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.

2 participants