-
Notifications
You must be signed in to change notification settings - Fork 0
feat: S14.10 custom-SD integrator guide + example (#549) #562
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #include "BddTargetCustomSd.h" | ||
|
|
||
| #include "SolidSyslogSdElement.h" | ||
| #include "SolidSyslogSdValue.h" | ||
| #include "SolidSyslogStructuredDataDefinition.h" | ||
|
|
||
| /* IANA-reserved "example" Private Enterprise Number — safe for documentation. */ | ||
| enum | ||
| { | ||
| EXAMPLE_ENTERPRISE_NUMBER = 32473U | ||
| }; | ||
|
|
||
| static void CustomSd_Format(struct SolidSyslogStructuredData* base, struct SolidSyslogSdElement* element) | ||
| { | ||
| (void) base; /* Stateless: this example emits a fixed element. */ | ||
|
|
||
| SolidSyslogSdElement_Begin(element, "example", EXAMPLE_ENTERPRISE_NUMBER); | ||
| SolidSyslogSdValue_String(SolidSyslogSdElement_Param(element, "detail"), "Hello World"); | ||
| SolidSyslogSdElement_End(element); | ||
| } | ||
|
|
||
| static struct SolidSyslogStructuredData customSd = {CustomSd_Format}; | ||
|
|
||
| struct SolidSyslogStructuredData* BddTargetCustomSd_Get(void) | ||
| { | ||
| return &customSd; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #ifndef BDDTARGETCUSTOMSD_H | ||
| #define BDDTARGETCUSTOMSD_H | ||
|
|
||
| #include "ExternC.h" | ||
|
|
||
| EXTERN_C_BEGIN | ||
|
|
||
| struct SolidSyslogStructuredData; | ||
|
|
||
| /* The worked custom SD-ELEMENT for the integrator guide | ||
| * (docs/structured-data.md). Emits [example@32473 detail="Hello World"]. | ||
| * Stateless singleton — handed to SolidSyslog_LogWithSd by the | ||
| * `send-custom` interactive command. */ | ||
| struct SolidSyslogStructuredData* BddTargetCustomSd_Get(void); | ||
|
|
||
| EXTERN_C_END | ||
|
|
||
| #endif /* BDDTARGETCUSTOMSD_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| @udp | ||
| Feature: Custom structured data — caller-supplied SD-ELEMENT | ||
| An integrator can attach a custom SD-ELEMENT to a single log call via | ||
| SolidSyslog_LogWithSd. The library frames it per RFC 5424 §6.3 and the | ||
| element reaches the receiver alongside the per-instance SDs. | ||
|
|
||
| Scenario: A custom SD-ELEMENT reaches the oracle | ||
| Given the syslog oracle is running | ||
| When the BDD target sends a custom syslog message | ||
| Then the structured data contains detail "Hello World" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #include "BddTargetCustomSd.h" | ||
| #include "SolidSyslogFormatter.h" | ||
| #include "SolidSyslogSdElement.h" | ||
| #include "SolidSyslogSdElementPrivate.h" | ||
| #include "SolidSyslogStructuredData.h" | ||
|
|
||
| #include "CppUTest/TestHarness.h" | ||
|
|
||
| enum | ||
| { | ||
| FORMATTER_BUFFER_SIZE = 128 | ||
| }; | ||
|
|
||
| // clang-format off | ||
| TEST_GROUP(BddTargetCustomSd) | ||
| { | ||
| SolidSyslogFormatterStorage storage[SOLIDSYSLOG_FORMATTER_STORAGE_SIZE(FORMATTER_BUFFER_SIZE)]; | ||
| struct SolidSyslogFormatter* formatter = nullptr; | ||
| struct SolidSyslogSdElement element{}; | ||
|
|
||
| void setup() override | ||
| { | ||
| formatter = SolidSyslogFormatter_Create(storage, FORMATTER_BUFFER_SIZE); | ||
| SolidSyslogSdElement_FromFormatter(&element, formatter); | ||
| } | ||
|
|
||
| [[nodiscard]] const char* formatted() const | ||
| { | ||
| return SolidSyslogFormatter_AsFormattedBuffer(formatter); | ||
| } | ||
| }; | ||
|
|
||
| // clang-format on | ||
|
|
||
| TEST(BddTargetCustomSd, EmitsTheExampleElement) | ||
| { | ||
| SolidSyslogStructuredData_Format(BddTargetCustomSd_Get(), &element); | ||
| STRCMP_EQUAL("[example@32473 detail=\"Hello World\"]", formatted()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update validation status to avoid stale release notes.
This “not yet run” note conflicts with the PR objective/status context indicating
custom_sd.featurealready passed. Please align this section with the final executed state (or add explicit run date/context if it was pending at entry time).🤖 Prompt for AI Agents