Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-1322

Consider doing away with double logger variables

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      For PR 5980, the primary classes that owned a reference to the Logger were updated to hold a shared_ptr instead of a reference to the logger held as a unique_ptr by the SyncManager. This improved the predictability of the lifetime of the logger, but also introduced a lot of changes.

      To minimize some of the changes, two variables are used when the shared_ptr is used:

      std::shared_ptr<util::Logger> logger_ptr;
      util::Logger& logger;  // initialized with logger{*logger_ptr};
      

      This allows the existing logger output calls to remain in tact, while updating the underlying storage of the logger, but can be confusing without context as to why the choice was made.

      Consider migrating the double variables to just use the shared_ptr. It is guaranteed that the owning object will have a logger initialized in the constructor, so checking the shared_ptr every time a logging function is called is not necessary. For extra verification, an ASSERT can be added to the body of the constructor to verify the Logger is not a nullptr.

            Assignee:
            Unassigned Unassigned
            Reporter:
            michael.wilkersonbarker@mongodb.com Michael Wilkerson-Barker (Inactive)
            AD Sync Client
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: