-
Notifications
You must be signed in to change notification settings - Fork 27
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
Feature/syslog structured data #122
Merged
jameshawkes
merged 7 commits into
ecmwf:develop
from
sametd:feature/syslog-structured-data
Jun 3, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f319ac
basic implementation for structured data (only for origin)
sametd 3662286
initial structured data implementation for syslog (only origin part)
sametd 7e4ee5d
clang-format
sametd 8b61679
spelling correction
sametd 65981d6
added tests for syslog class
sametd 52ba689
added syslog test
sametd a726bd8
Merge branch 'ecmwf:develop' into feature/syslog-structured-data
sametd 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 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 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 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 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,84 @@ | ||
/* | ||
* (C) Copyright 1996- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation nor | ||
* does it submit to any jurisdiction. | ||
*/ | ||
|
||
#include <iostream> | ||
|
||
#include "eckit/log/SysLog.h" | ||
#include "eckit/testing/Test.h" | ||
|
||
using namespace std; | ||
using namespace eckit; | ||
using namespace eckit::testing; | ||
|
||
namespace eckit::test { | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
CASE("test_priority") { | ||
SysLog log("Test message", 0, SysLog::Local7, SysLog::Info); | ||
std::string logString = static_cast<std::string>(log); | ||
std::string expectedPriority = "<" + std::to_string(log.priority()) + ">"; | ||
EXPECT(logString.find(expectedPriority) != std::string::npos); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
CASE("test_timezone") { | ||
SysLog log("Test message", 0, SysLog::Local7, SysLog::Info); | ||
std::string logString = static_cast<std::string>(log); | ||
// Check if 'Z' UTC indicator is present | ||
EXPECT(logString.find("Z") != std::string::npos); | ||
// Check if 'T' separator is present | ||
EXPECT(logString.find("T") != std::string::npos); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
CASE("test_appname") { | ||
SysLog log("Test message", 0, SysLog::Local7, SysLog::Info); | ||
EXPECT(log.appName() == Main::instance().name()); | ||
|
||
// Change the appName and check if it persists | ||
log.appName("test_app"); | ||
std::string logString = static_cast<std::string>(log); | ||
EXPECT(logString.find("test_app") != std::string::npos); | ||
|
||
// Create a new SysLog instance and check if it retains the original appName | ||
SysLog newLog("New message", 2, SysLog::Local7, SysLog::Info); | ||
EXPECT(newLog.appName() == Main::instance().name()); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
CASE("test_without_structured_data") { | ||
SysLog log("Test message", 0, SysLog::Local7, SysLog::Info); | ||
std::string logString = static_cast<std::string>(log); | ||
// Check if structured data is not present | ||
EXPECT(logString.find("[origin") == std::string::npos); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
CASE("test_with_structured_data") { | ||
SysLog log("Test message", 0, SysLog::Local7, SysLog::Info); | ||
log.software("log_test"); | ||
log.swVersion("1.0.0"); | ||
log.enterpriseId("7464"); | ||
std::string logString = static_cast<std::string>(log); | ||
EXPECT(logString.find("enterpriseId=\"7464\"") != std::string::npos); | ||
EXPECT(logString.find("software=\"log_test\"") != std::string::npos); | ||
EXPECT(logString.find("swVersion=\"1.0.0\"") != std::string::npos); | ||
} | ||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
} // namespace eckit::test | ||
|
||
int main(int argc, char** argv) { | ||
return run_tests(argc, argv); | ||
} |
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.
Where are these being set?
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.
These are the keywords that belongs to origin part of the syslog structural data described in RFC5424 -> https://datatracker.ietf.org/doc/html/rfc5424#section-7.2