Skip to content

feat(os): add Linux syslog OS wrapper for score::os::Syslog - #502

Open
btirunagaru wants to merge 1 commit into
eclipse-score:mainfrom
qualcomm:feat/syslog_on_linux
Open

btirunagaru wants to merge 1 commit into
eclipse-score:mainfrom
qualcomm:feat/syslog_on_linux

Conversation

@btirunagaru

Copy link
Copy Markdown

Description

Adds score::os::Syslog, a new OS-abstraction wrapper (interface +
impl + mock) around glibc's openlog(3)/syslog(3)/closelog(3),
following the existing score::os::qnx::Slog2 pattern. Includes unit
tests under score/os/test/linux/, reusing the existing generic
OS-wrapper requirement SCR-46010294.

This is a prerequisite for a companion contribution to the logging
component (eclipse-score/logging#270), which consumes
@score_baselibs//score/os:syslog to implement the LogMode::kSystem
backend for mw::log on Linux.

Related ticket

closes #501

@github-project-automation github-project-automation Bot moved this to In Progress in BAS - Baselibs FT Aug 21, 2026
@btirunagaru
btirunagaru deployed to workflow-approval August 21, 2026 19:47 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 21, 2026 19:47 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 21, 2026 19:47 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 21, 2026 19:47 — with GitHub Actions Active
@github-actions github-actions Bot added comp-osal Related to score/os component c++ C++ code bazel Bazel and Starlark build files labels Aug 21, 2026
Comment thread score/os/syslog.h Outdated
public:
static score::cpp::pmr::unique_ptr<Syslog> Default(score::cpp::pmr::memory_resource* memory_resource) noexcept;

/* KW_SUPPRESS_START:MISRA.VAR.HIDDEN:Wrapper function is identifiable through namespace usage */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please do not add KW_ markers. These are legacy and should actually be removed from the entire codebase.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. Fixed in the new review.

Comment thread score/os/syslog.h Outdated
Syslog() = default;

virtual ~Syslog() = default;
// Below special member functions declared to avoid autosar_cpp14_a12_0_1_violation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please do not add this comment. This repo aims to adhere to MISRA guidelines and not AUTOSAR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. Fixed in the new review.

Comment thread score/os/mocklib/mock_syslog.cpp Outdated
@@ -0,0 +1,52 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please set year to 2026 everywhere

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. Fixed in the new review.

Comment thread score/os/syslog.h Outdated

/// @brief Object-seam wrapper around the POSIX/glibc syslog(3) family.
///
/// Mirrors the QNX @ref score::os::qnx::Slog2 wrapper so that the platform-native

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment looks redundant. The slog2 API is completely different.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. Fixed in the new review.

Comment thread score/os/BUILD
],
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
target_compatible_with = ["@platforms//os:linux"],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

QNX has syslog API as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

But the idea to use slog on qnx and only syslog on linux providing the equivalent functionality on target.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not to give freedom to use it also on QNX? I would add qnx target as far as code is the same

@btirunagaru btirunagaru Aug 26, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

as i mentioned - the kSystem log mode on QNX is already filled by slog and its widely used on QNX and it make sense to use that.
so i would assume the choice of the users to use slog vs syslog on QNX is more of a different ask. Till the community show interest to have this dual choice. its best we treat this and compile for Linux only and enable for QNX later (until we find a genuine user for this back end)
If there is a interest and the enablement for QNX can come later as a different requirement if that's the need.

@btirunagaru
btirunagaru deployed to workflow-approval August 24, 2026 18:03 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 24, 2026 18:03 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 24, 2026 18:03 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 24, 2026 18:03 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 26, 2026 18:31 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 26, 2026 18:31 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 26, 2026 18:31 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval August 26, 2026 18:31 — with GitHub Actions Active
@btirunagaru
btirunagaru marked this pull request as ready for review August 26, 2026 18:32
@btirunagaru
btirunagaru requested a review from 4og August 27, 2026 18:34
@btirunagaru
btirunagaru deployed to workflow-approval September 2, 2026 18:45 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval September 2, 2026 18:45 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval September 2, 2026 18:45 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval September 2, 2026 18:45 — with GitHub Actions Active
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-502: https://eclipse-score.github.io/baselibs/pr-502/

@btirunagaru

Copy link
Copy Markdown
Author

Hi @btirunagaru, Can you please update the branch and address the remaining CI issues?

Yes, i raised another commit with fixes for those CI workflows - please review.

Comment thread score/os/syslog_impl.cpp Outdated
::openlog(ident, option, facility);
}

// coverity[autosar_cpp14_a8_4_1_violation]: see above

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not see any argumentation for the suppression.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@4og

Please do not add KW_ markers. These are legacy and should actually be removed from the entire codebase.

This was the comment provided to me earlier so had to remove those annotation or argumentation - see my first review those should be there - let me know if you want me to bring it in.

Comment thread score/os/syslog_impl.h Outdated
const std::int32_t option,
const std::int32_t facility) const noexcept override;

// coverity[autosar_cpp14_a8_4_1_violation]: see above

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see above?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@rmaddikery done cleaned up -squashed both PRs.

@github-actions github-actions Bot added the comp-flatbuffers Related to score/flatbuffers component label Sep 10, 2026
@github-actions github-actions Bot removed the comp-flatbuffers Related to score/flatbuffers component label Sep 10, 2026
Add a Linux implementation of the Syslog object seam that forwards openlog(), syslog(), and closelog() calls to the POSIX API.

- Add the Syslog interface, Linux implementation, and default factory.
- Add a mock implementation and Linux unit tests.
- Include the production implementation in the coverage scope.
- Preserve the POSIX-compatible C-style variadic interface.
- Retain only the required clang-tidy suppressions for the variadic adapters.
- Remove the stale Coverity 'see above' comments from the Linux syslog declaration and definition.

Verification:
- Linux syslog unit test passed.
- C++ formatting check passed.
- Targeted clang-tidy build passed.
- Coverage scope check passed.
- git diff --check passed.
@btirunagaru
btirunagaru deployed to workflow-approval September 11, 2026 18:07 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval September 11, 2026 18:07 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval September 11, 2026 18:07 — with GitHub Actions Active
@btirunagaru
btirunagaru deployed to workflow-approval September 11, 2026 18:07 — with GitHub Actions Active
#include <cstdio>
#include <string>

namespace score
void MockSyslog::syslog(std::int32_t priority, const char* format, ...) const noexcept
{
// Create a va_list to hold the variable arguments
va_list args;
{
// Create a va_list to hold the variable arguments
va_list args;
va_start(args, format);
va_start(args, format);

// Determine required buffer size
const auto message_length = std::vsnprintf(nullptr, 0, format, args);
const auto message_length = std::vsnprintf(nullptr, 0, format, args);

// Reset the va_list to be able to use it again
va_end(args);

// Googletest does not support variadic arguments. Therefore we pass through the formatted string so that we can
// use it with MOCK_METHOD.
MOCK_METHOD(void, MockedSyslog, (std::int32_t priority, const std::string& message), (const, noexcept));
Comment thread score/os/syslog.cpp

#include "score/os/syslog_impl.h"

namespace score
Comment thread score/os/syslog.h

#include <syslog.h>

namespace score
Comment thread score/os/syslog_impl.cpp

#include <cstdarg>

namespace score
Comment thread score/os/syslog_impl.h

#include "score/os/syslog.h"

namespace score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bazel Bazel and Starlark build files c++ C++ code comp-osal Related to score/os component

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

feat: Add Linux syslog OS wrapper (score::os::Syslog)

5 participants