Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-43750

refactor log_detail.cpp and log_detail.h

    • Type: Icon: Improvement Improvement
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      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?
      

            Assignee:
            backlog-server-devtools DO NOT USE - Backlog - Dev Tools
            Reporter:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: