-
Notifications
You must be signed in to change notification settings - Fork 440
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
[API] DO not allow unsafe Logger::EmitLogRecord
#2673
[API] DO not allow unsafe Logger::EmitLogRecord
#2673
Conversation
@@ -145,6 +146,10 @@ struct LogRecordSetterTrait<common::KeyValueIterable> | |||
template <class ValueType> | |||
struct LogRecordSetterTrait | |||
{ | |||
static_assert(!std::is_same<nostd::unique_ptr<LogRecord>, ValueType>::value && | |||
!std::is_same<std::unique_ptr<LogRecord>, ValueType>::value, | |||
"unique_ptr<LogRecord> is not allowed"); |
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.
"unique_ptr<LogRecord> is not allowed"); | |
"unique_ptr<LogRecord> is not allowed, use std::move()"); |
Also, consider adding an assert for LogRecord*
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.
Thanks, it's done
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.
Thanks for the fix, see suggestion.
Logger::EmitLogRecord
Logger::EmitLogRecord
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2673 +/- ##
==========================================
+ Coverage 87.12% 87.70% +0.58%
==========================================
Files 200 190 -10
Lines 6109 5852 -257
==========================================
- Hits 5322 5132 -190
+ Misses 787 720 -67
|
…t/opentelemetry-cpp into do_now_allow_emit_unsafe_log_record
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.
LGTM, thanks for the fix.
Fixes #2666
Changes
Logger::EmitLogRecord
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes