1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PLATFORM_API_TRACE_LOGGING_PLATFORM_H_ 6 #define PLATFORM_API_TRACE_LOGGING_PLATFORM_H_ 7 8 #include "platform/api/time.h" 9 #include "platform/base/error.h" 10 #include "platform/base/trace_logging_activation.h" 11 #include "platform/base/trace_logging_types.h" 12 13 namespace openscreen { 14 15 // Optional platform API to support logging trace events from Open Screen. To 16 // use this, implement the TraceLoggingPlatform interface and call 17 // StartTracing() and StopTracing() to turn tracing on/off (see 18 // platform/base/trace_logging_activation.h). 19 // 20 // All methods must be thread-safe and re-entrant. 21 class TraceLoggingPlatform { 22 public: 23 virtual ~TraceLoggingPlatform(); 24 25 // Determines whether trace logging is enabled for the given category. 26 virtual bool IsTraceLoggingEnabled(TraceCategory::Value category) = 0; 27 28 // Log a synchronous trace. 29 virtual void LogTrace(const char* name, 30 const uint32_t line, 31 const char* file, 32 Clock::time_point start_time, 33 Clock::time_point end_time, 34 TraceIdHierarchy ids, 35 Error::Code error) = 0; 36 37 // Log an asynchronous trace start. 38 virtual void LogAsyncStart(const char* name, 39 const uint32_t line, 40 const char* file, 41 Clock::time_point timestamp, 42 TraceIdHierarchy ids) = 0; 43 44 // Log an asynchronous trace end. 45 virtual void LogAsyncEnd(const uint32_t line, 46 const char* file, 47 Clock::time_point timestamp, 48 TraceId trace_id, 49 Error::Code error) = 0; 50 }; 51 52 } // namespace openscreen 53 54 #endif // PLATFORM_API_TRACE_LOGGING_PLATFORM_H_ 55