-
Notifications
You must be signed in to change notification settings - Fork 1
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
Logging API and SDK modifications #12
Conversation
@@ -59,47 +58,51 @@ class Logger | |||
* A default LogRecord that will be assigned if no parameters are passed to Logger's .log() method | |||
* which should at minimum assign the trace_id, span_id, and timestamp | |||
*/ | |||
virtual void log(const LogRecord &record) noexcept = 0; | |||
virtual void Log(LogRecord &record) noexcept = 0; |
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.
const?
api/test/logs/logger_test.cc
Outdated
logger->log(r); | ||
r.name = "Log Record"; | ||
r.severity = Severity::kInfo; | ||
logger->Log(r); |
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.
Verify what log record actually gets created by Log() methods?
|
||
/** | ||
* Writes a log record into the processor. | ||
* @param record The record to write into the processor. | ||
*/ | ||
void log(const opentelemetry::logs::LogRecord &record) noexcept override; | ||
void Log(opentelemetry::logs::LogRecord &record) noexcept override; |
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.
No more const?
sdk/src/logs/logger.cc
Outdated
// Inject values into record if not user specified | ||
// Timestamp | ||
if (r->timestamp == opentelemetry::core::SystemTimestamp(std::chrono::seconds(0))) | ||
r->timestamp = core::SystemTimestamp(std::chrono::system_clock::now()); |
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.
For consistency with other single line if statements recommend using { and }
auto logger = lp->GetLogger("TestLogger"); | ||
|
||
// GetLogger(name, args) function | ||
std::array<string_view, 1> sv{"string"}; |
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.
no harm in leaving this in?
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.
Yup it's still in but the GitHub diff tool said that it was taken out and readded somewhere else... confusing
std::array<string_view, 1> sv{"string"}; | ||
span<string_view> args{sv}; | ||
auto logger2 = lp->GetLogger("TestLogger2", args); | ||
ASSERT_EQ("test logger", logger->GetName()); |
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.
Add ASSERT_EQ(logger2->GetName(), "TestLogger2")
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.
The API implementation returns a noop instance, so the name would always be "noop logger" which is what the first test checks for
@@ -39,8 +39,7 @@ class Logger | |||
virtual ~Logger() = default; | |||
|
|||
/* Returns the name of the logger */ | |||
// TODO: decide whether this is useful and/or should be kept, as this is not a method required in | |||
// the specification. virtual nostd::string_view getName() = 0; | |||
virtual nostd::string_view GetName() noexcept = 0; |
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.
Make const?
…try-cpp into logs-API-SDK-update
This PR addresses many of the comments we received when we PRed the initial Logging API and initial Logging SDK.
GetName()
method to logger API and SDK.Note this PR relies on #403 to be merged to compile.
cc - @alolita @xukaren