Move platform/api/trace_logging.h → util/trace_logging.h, etc...
This change moves the parts of trace logging that are library code (and
not platform specific) into util or platform/base, as appropriate.
Library code using the tracing macros is pointed to
util/trace_logging.h. Overall, this "minifies" the platform/api an
embedder must implement to just the TraceLoggerPlatform interface.
Removed "enable flag" from build config, and started a new features.h
config. Will revisit this mechanism in a future change (and consolidate
other feature flags). Fixed issues related to enabling the feature (bots
were not verifying anything because it had been left off).
Fixed a few C++ style issues found in code as it was moved around.
This change also fixes unit test crashing due to dangling pointers to
detsroyed MockLoggingPlatforms being left around (the global pointer was
not being nulled-out after the tracing unit tests were executed). To
simplify, the ctor/dtor now automatically set/clear the global pointer.
The crashing seems not to have been discovered because the BUILD.gn arg
"enable_trace_logging" defaults to false and so our bots were not
testing things. Will revisit this in a later change...
Bug: openscreen:77
Change-Id: I638a3998af0a3aacf4d8b8e0f059b331582313cb
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1920299
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Reviewed-by: mark a. foltz <mfoltz@chromium.org>
diff --git a/platform/impl/task_runner.h b/platform/impl/task_runner.h
index 81799f7..35da181 100644
--- a/platform/impl/task_runner.h
+++ b/platform/impl/task_runner.h
@@ -15,10 +15,11 @@
#include "absl/base/thread_annotations.h"
#include "absl/types/optional.h"
+#include "build/config/features.h"
#include "platform/api/task_runner.h"
#include "platform/api/time.h"
-#include "platform/api/trace_logging.h"
#include "platform/base/error.h"
+#include "util/trace_logging.h"
namespace openscreen {
namespace platform {
@@ -72,7 +73,7 @@
void RequestStopSoon();
private:
-#ifndef TRACE_FORCE_DISABLE
+#if defined(ENABLE_TRACE_LOGGING)
// Wrapper around a Task used to store the TraceId Metadata along with the
// task itself, and to set the current TraceIdHierarchy before executing the
// task.
@@ -93,9 +94,9 @@
Task task_;
TraceIdHierarchy trace_ids_;
};
-#else // TRACE_FORCE_DISABLE defined
+#else // !defined(ENABLE_TRACE_LOGGING)
using TaskWithMetadata = Task;
-#endif // TRACE_FORCE_DISABLE
+#endif // defined(ENABLE_TRACE_LOGGING)
// Helper that runs all tasks in |running_tasks_| and then clears it.
void RunRunnableTasks();