| /* |
| * Copyright (c) 2023 Project CHIP Authors |
| * All rights reserved. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| #include <lib/support/IntrusiveList.h> |
| |
| #include <platform/LockTracker.h> |
| #include <tracing/registry.h> |
| |
| namespace chip { |
| namespace Tracing { |
| namespace { |
| |
| IntrusiveList<Backend> gTracingBackends; |
| |
| } // namespace |
| |
| void Register(Backend & backend) |
| { |
| assertChipStackLockedByCurrentThread(); |
| gTracingBackends.PushBack(&backend); |
| } |
| |
| void Unregister(Backend & backend) |
| { |
| assertChipStackLockedByCurrentThread(); |
| gTracingBackends.Remove(&backend); |
| } |
| |
| #ifdef MATTER_TRACING_ENABLED |
| |
| namespace Internal { |
| |
| void Begin(::chip::Tracing::Scope scope) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.TraceBegin(scope); |
| } |
| } |
| |
| void End(::chip::Tracing::Scope scope) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.TraceEnd(scope); |
| } |
| } |
| void Instant(::chip::Tracing::Instant instant) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.TraceInstant(instant); |
| } |
| } |
| |
| void LogMessageSend(::chip::Tracing::MessageSendInfo & info) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.LogMessageSend(info); |
| } |
| } |
| |
| void LogMessageReceived(::chip::Tracing::MessageReceivedInfo & info) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.LogMessageReceived(info); |
| } |
| } |
| |
| void LogNodeLookup(::chip::Tracing::NodeLookupInfo & info) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.LogNodeLookup(info); |
| } |
| } |
| |
| void LogNodeDiscovered(::chip::Tracing::NodeDiscoveredInfo & info) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.LogNodeDiscovered(info); |
| } |
| } |
| |
| void LogNodeDiscoveryFailed(::chip::Tracing::NodeDiscoveryFailedInfo & info) |
| { |
| for (auto & backend : gTracingBackends) |
| { |
| backend.LogNodeDiscoveryFailed(info); |
| } |
| } |
| |
| } // namespace Internal |
| |
| #endif // MATTTER_TRACING_ENABLED |
| |
| } // namespace Tracing |
| } // namespace chip |