|
20 | 20 | #include <util/test_path.hpp> |
21 | 21 |
|
22 | 22 | #include <realm/util/features.h> |
| 23 | +#include <realm/util/logger.hpp> |
23 | 24 | #include <realm/util/to_string.hpp> |
24 | 25 |
|
25 | 26 | #if TEST_SCHEDULER_UV |
|
38 | 39 | #include <iostream> |
39 | 40 | #include <limits.h> |
40 | 41 |
|
| 42 | +#ifndef TEST_ENABLE_LOGGING |
| 43 | +#define TEST_ENABLE_LOGGING 0 // change to 1 to enable trace-level logging |
| 44 | +#endif |
| 45 | + |
| 46 | +#ifndef TEST_LOGGING_LEVEL |
| 47 | +#if TEST_ENABLE_LOGGING |
| 48 | +#define TEST_LOGGING_LEVEL all |
| 49 | +#else |
| 50 | +#define TEST_LOGGING_LEVEL off |
| 51 | +#endif // TEST_ENABLE_LOGGING |
| 52 | +#endif // TEST_LOGGING_LEVEL |
| 53 | + |
| 54 | +#define TEST_LOGGING_LEVEL_STORAGE off |
| 55 | +#define TEST_LOGGING_LEVEL_SERVER off |
| 56 | +/* |
| 57 | +#define TEST_LOGGING_LEVEL_SYNC off |
| 58 | +#define TEST_LOGGING_LEVEL_RESET trace |
| 59 | +#define TEST_LOGGING_LEVEL_APP off |
| 60 | +*/ |
| 61 | + |
| 62 | +static std::vector<std::pair<std::string_view, realm::util::Logger::Level>> default_log_levels = { |
| 63 | + {"Realm", realm::util::Logger::Level::TEST_LOGGING_LEVEL}, |
| 64 | +#ifdef TEST_LOGGING_LEVEL_STORAGE |
| 65 | + {"Realm.Storage", realm::util::Logger::Level::TEST_LOGGING_LEVEL_STORAGE}, |
| 66 | +#endif |
| 67 | +#ifdef TEST_LOGGING_LEVEL_TRANSACTION |
| 68 | + {"Realm.Storage.Transaction", realm::util::Logger::Level::TEST_LOGGING_LEVEL_TRANSACTION}, |
| 69 | +#endif |
| 70 | +#ifdef TEST_LOGGING_LEVEL_QUERY |
| 71 | + {"Realm.Storage.Query", realm::util::Logger::Level::TEST_LOGGING_LEVEL_QUERY}, |
| 72 | +#endif |
| 73 | +#ifdef TEST_LOGGING_LEVEL_OBJECT |
| 74 | + {"Realm.Storage.Object", realm::util::Logger::Level::TEST_LOGGING_LEVEL_OBJECT}, |
| 75 | +#endif |
| 76 | +#ifdef TEST_LOGGING_LEVEL_NOTIFICATION |
| 77 | + {"Realm.Storage.Notification", realm::util::Logger::Level::TEST_LOGGING_LEVEL_NOTIFICATION}, |
| 78 | +#endif |
| 79 | +#ifdef TEST_LOGGING_LEVEL_SYNC |
| 80 | + {"Realm.Sync", realm::util::Logger::Level::TEST_LOGGING_LEVEL_SYNC}, |
| 81 | +#endif |
| 82 | +#ifdef TEST_LOGGING_LEVEL_CLIENT |
| 83 | + {"Realm.Sync.Client", realm::util::Logger::Level::TEST_LOGGING_LEVEL_CLIENT}, |
| 84 | +#endif |
| 85 | +#ifdef TEST_LOGGING_LEVEL_SESSION |
| 86 | + {"Realm.Sync.Client.Session", realm::util::Logger::Level::TEST_LOGGING_LEVEL_SESSION}, |
| 87 | +#endif |
| 88 | +#ifdef TEST_LOGGING_LEVEL_CHANGESET |
| 89 | + {"Realm.Sync.Client.Changeset", realm::util::Logger::Level::TEST_LOGGING_LEVEL_CHANGESET}, |
| 90 | +#endif |
| 91 | +#ifdef TEST_LOGGING_LEVEL_NETWORK |
| 92 | + {"Realm.Sync.Client.Network", realm::util::Logger::Level::TEST_LOGGING_LEVEL_NETWORK}, |
| 93 | +#endif |
| 94 | +#ifdef TEST_LOGGING_LEVEL_RESET |
| 95 | + {"Realm.Sync.Client.Reset", realm::util::Logger::Level::TEST_LOGGING_LEVEL_RESET}, |
| 96 | +#endif |
| 97 | +#ifdef TEST_LOGGING_LEVEL_SERVER |
| 98 | + {"Realm.Sync.Server", realm::util::Logger::Level::TEST_LOGGING_LEVEL_SERVER}, |
| 99 | +#endif |
| 100 | +#ifdef TEST_LOGGING_LEVEL_APP |
| 101 | + {"Realm.App", realm::util::Logger::Level::TEST_LOGGING_LEVEL_APP}, |
| 102 | +#endif |
| 103 | +}; |
| 104 | + |
| 105 | +static void set_default_level_thresholds() |
| 106 | +{ |
| 107 | + for (auto [cat, level] : default_log_levels) { |
| 108 | + realm::util::LogCategory::get_category(cat).set_default_level_threshold(level); |
| 109 | + } |
| 110 | +} |
| 111 | + |
41 | 112 |
|
42 | 113 | int run_object_store_tests(int argc, const char** argv); |
43 | 114 |
|
@@ -91,6 +162,8 @@ int run_object_store_tests(int argc, const char** argv) |
91 | 162 | }); |
92 | 163 | #endif |
93 | 164 |
|
| 165 | + set_default_level_thresholds(); |
| 166 | + |
94 | 167 | Catch::Session session; |
95 | 168 | session.useConfigData(config); |
96 | 169 | int result = session.run(argc, argv); |
|
0 commit comments