[SERVER-43750] refactor log_detail.cpp and log_detail.h Created: 01/Oct/19  Updated: 27/Oct/23  Resolved: 03/Dec/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Gabriel Russell (Inactive) Assignee: DO NOT USE - Backlog - Dev Tools
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Developer Tools
Participants:

 Description   

billy.donahue 2019/10/01 19:39:57
Even here for this short-term code I really strongly dislike the copy-paste.
I have to eyeball every line of doLogImpl function and doLogRecordImpl to see
how they differ.
 
There are two big functions that are mostly the same.
Inside each are two big statements that are mostly the same too.
Would something like this make sense to orthogonalize this stuff?
 
template <typename K, typename V>
void insertRecord(LogRecord& record, K&& key, V&& obj) {
        auto impl = boost::intrusive_ptr(
            new boost::log::attributes::attribute_value_impl<V>(obj));
        record.attribute_values().insert(
            key,
            boost::log::attribute_value(std::move(impl)));
}
 
void doLogImpl(LogSeverity const& severity,
               LogOptions const& options,
               StringData stable_id,
               StringData message,
               AttributeArgumentSet const& attrs) {
  auto& source = options.domain().impl().source();
  auto record = source.open_record(
        severity, options.component(),
        options.tags(), stable_id);
  doLogRecordImpl(std::move(record), options.domain(), message, attrs);
}
 
void doLogRecordImpl(LogRecord&& record,
                     LogDomain& domain,
                     StringData message,
                     AttributeArgumentSet const& attrs) {
    auto& source = domain.impl().source();
    auto record = std::move(record.impl()->_record);
    if (record) {
      insertRecord(record, attributes::message(), message);
      insertRecord(record, attributes::attributes(), attrs);
      source.push_record(std::move(record));
    }
}

also

+inline fmt::internal::udl_arg<char> operator"" _attr(const char* s, std::size_t) {
 
> Is this `internal` abstraction break necessary?
> Maybe use auto return type or something?
> 
> Should be constexpr, no?



 Comments   
Comment by Henrik Edin [ 03/Dec/19 ]

LogRecord is now gone so this is not a problem anymore.

Generated at Thu Feb 08 05:04:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.