Skip to content
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

Update return type of LogCategory::get_category_names() from std::vector<const char*> to std::vector<std::string_view> #7879

Merged
merged 6 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# NEXT RELEASE

### Enhancements
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
* None.
* Updated the return type of `LogCategory::get_category_names()` from `std::vector<const char*>` to `std::vector<std::string_view>`. ([PR #7879](https://github.com/realm/realm-core/pull/7879))

### Fixed
* When a public name is defined on a property, calling `realm::Results::sort()` or `realm::Results::distinct()` with the internal name could throw an error like `Cannot sort on key path 'NAME': property 'PersonObject.NAME' does not exist`. ([realm/realm-js#6779](https://github.com/realm/realm-js/issues/6779), since v12.12.0)
Expand All @@ -23,14 +22,14 @@
# 14.10.3 Release notes

### Enhancements
* "Next launch" metadata file actions are now performed in a multi-process safe manner ([#7576](https://github.com/realm/realm-core/pull/7576)).
* "Next launch" metadata file actions are now performed in a multi-process safe manner. ([PR #7576](https://github.com/realm/realm-core/pull/7576))

### Fixed
* Fixed a change of mode from Strong to All when removing links from an embedded object that links to a tombstone. This affects sync apps that use embedded objects which have a `Lst<Mixed>` that contains a link to another top level object which has been deleted by another sync client (creating a tombstone locally). In this particular case, the switch would cause any remaining link removals to recursively delete the destination object if there were no other links to it. ([#7828](https://github.com/realm/realm-core/issues/7828), since 14.0.0-beta.0)
* Fixed removing backlinks from the wrong objects if the link came from a nested list, nested dictionary, top-level dictionary, or list of mixed, and the source table had more than 256 objects. This could manifest as `array_backlink.cpp:112: Assertion failed: int64_t(value >> 1) == key.value` when removing an object. ([#7594](https://github.com/realm/realm-core/issues/7594), since v11 for dictionaries)
* Fixed the collapse/rejoin of clusters which contained nested collections with links. This could manifest as `array.cpp:319: Array::move() Assertion failed: begin <= end [2, 1]` when removing an object. ([#7839](https://github.com/realm/realm-core/issues/7839), since the introduction of nested collections in v14.0.0-beta.0)
* wait_for_upload_completion() was inconsistent in how it handled commits which did not produce any changesets to upload. Previously it would sometimes complete immediately if all commits waiting to be uploaded were empty, and at other times it would wait for a server roundtrip. It will now always complete immediately. ([PR #7796](https://github.com/realm/realm-core/pull/7796)).
* `realm_sync_session_handle_error_for_testing` parameter `is_fatal` was flipped changing the expected behavior. (#[7750](https://github.com/realm/realm-core/issues/7750)).
* `realm_sync_session_handle_error_for_testing` parameter `is_fatal` was flipped changing the expected behavior. ([#7750](https://github.com/realm/realm-core/issues/7750))

### Breaking changes
* None.
Expand Down
2 changes: 1 addition & 1 deletion src/realm/object-store/c_api/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ RLM_API size_t realm_get_category_names(size_t num_values, const char** out_valu
if (number_to_copy > num_values)
number_to_copy = num_values;
for (size_t n = 0; n < number_to_copy; n++) {
out_values[n] = vec[n];
out_values[n] = vec[n].data();
}
}
return number_to_copy;
Expand Down
15 changes: 8 additions & 7 deletions src/realm/util/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ std::shared_ptr<util::Logger> s_default_logger;
} // anonymous namespace

size_t LogCategory::s_next_index = 0;
static std::map<std::string_view, LogCategory*> log_catagory_map;
static std::map<std::string_view, LogCategory*> log_category_map;

LogCategory LogCategory::realm("Realm", nullptr);
LogCategory LogCategory::storage("Storage", &realm);
Expand Down Expand Up @@ -58,19 +58,20 @@ LogCategory::LogCategory(std::string_view name, LogCategory* parent)
parent->m_children.push_back(this);
}
m_name += name;
log_catagory_map.emplace(m_name, this);
log_category_map.emplace(m_name, this);
}

LogCategory& LogCategory::get_category(std::string_view name)
{
return *log_catagory_map.at(name); // Throws
return *log_category_map.at(name); // Throws
}

std::vector<const char*> LogCategory::get_category_names()
std::vector<std::string_view> LogCategory::get_category_names()
{
std::vector<const char*> ret;
for (auto& it : log_catagory_map) {
ret.push_back(it.second->get_name().c_str());
std::vector<std::string_view> ret;
ret.reserve(log_category_map.size());
for (auto& it : log_category_map) {
ret.push_back(it.second->get_name());
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/realm/util/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class LogCategory {
// Find category from fully qualified name. Will throw if
// name does not match a category
static LogCategory& get_category(std::string_view name);
static std::vector<const char*> get_category_names();
static std::vector<std::string_view> get_category_names();

private:
friend class Logger;
Expand Down
Loading