-
Notifications
You must be signed in to change notification settings - Fork 188
Allow to set logging level through env var for object store tests #7344
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,20 +152,12 @@ if(REALM_ENABLE_SYNC) | |
| endif() | ||
| endif() | ||
|
|
||
| if(REALM_TEST_LOGGING) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend keeping the TEST_ENABLE_LOGGING value so it works like before (based on the logic in test_file.hpp) and update the logic to something like this: |
||
| target_compile_definitions(ObjectStoreTestLib PRIVATE | ||
| TEST_ENABLE_LOGGING=1 | ||
| ) | ||
|
|
||
| if(REALM_TEST_LOGGING_LEVEL) | ||
| message(STATUS "Test logging level: ${REALM_TEST_LOGGING_LEVEL}") | ||
| target_compile_definitions(ObjectStoreTestLib PRIVATE | ||
| TEST_LOGGING_LEVEL=${REALM_TEST_LOGGING_LEVEL} | ||
| ) | ||
| else() | ||
| message(STATUS "Test logging enabled") | ||
| endif() | ||
| set(REALM_TEST_LOGGING_LEVEL "off" CACHE STRING "Object-store tests logging level") | ||
| if ("${REALM_TEST_LOGGING_LEVEL}" STREQUAL "") | ||
| set(REALM_TEST_LOGGING_LEVEL "off" CACHE STRING "Object-store tests logging level" FORCE) | ||
| endif() | ||
| message(STATUS "Test logging level: ${REALM_TEST_LOGGING_LEVEL}") | ||
| target_compile_definitions(ObjectStoreTestLib PRIVATE TEST_LOGGING_LEVEL=${REALM_TEST_LOGGING_LEVEL}) | ||
|
|
||
| # Optional extra time to add to test timeout values | ||
| if(REALM_TEST_TIMEOUT_EXTRA) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,7 @@ TestFile::TestFile() | |
| disable_sync_to_disk(); | ||
| m_temp_dir = util::make_temp_dir(); | ||
| path = (fs::path(m_temp_dir) / "realm.XXXXXX").string(); | ||
| util::Logger::set_default_level_threshold(realm::util::Logger::Level::TEST_LOGGING_LEVEL); | ||
| util::Logger::set_default_level_threshold(TestSyncManager::default_log_level()); | ||
| if (const char* crypt_key = test_util::crypt_key()) { | ||
| encryption_key = std::vector<char>(crypt_key, crypt_key + 64); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to address line 200 of this file, since it also uses the |
||
|
|
@@ -340,7 +340,7 @@ TestAppSession::TestAppSession(AppSession session, | |
| if (!m_transport) | ||
| m_transport = instance_of<SynchronousTestTransport>; | ||
| auto app_config = get_config(m_transport, *m_app_session); | ||
| util::Logger::set_default_level_threshold(realm::util::Logger::Level::TEST_LOGGING_LEVEL); | ||
| util::Logger::set_default_level_threshold(TestSyncManager::default_log_level()); | ||
| set_app_config_defaults(app_config, m_transport); | ||
|
|
||
| util::try_make_dir(m_base_file_path); | ||
|
|
@@ -423,6 +423,21 @@ std::vector<bson::BsonDocument> TestAppSession::get_documents(SyncUser& user, co | |
|
|
||
| // MARK: - TestSyncManager | ||
|
|
||
| TestSyncManager::LoggerLevel TestSyncManager::default_log_level() | ||
| { | ||
| #ifndef TEST_LOGGING_LEVEL | ||
| #define TEST_LOGGING_LEVEL off | ||
| #endif | ||
|
|
||
| static LoggerLevel log_level = []() { | ||
| LoggerLevel level = LoggerLevel::TEST_LOGGING_LEVEL; | ||
| realm::util::Logger::get_env_log_level_if_set(level); | ||
| return level; | ||
| }(); | ||
|
|
||
| return log_level; | ||
| } | ||
|
|
||
| TestSyncManager::TestSyncManager(const Config& config, const SyncServer::Config& sync_server_config) | ||
| : transport(config.transport ? config.transport : std::make_shared<Transport>(network_callback)) | ||
| , m_sync_server(sync_server_config) | ||
|
|
||
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.
Recommend moving this to the test directory (e.g.
test/util/) instead of the Core base.