2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/trace/generic/trace-manager-impl-generic.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/internal/system/common/performance-interface.h>
26 #include <dali/devel-api/adaptor-framework/environment-variable.h>
27 #include <dali/internal/system/common/environment-variables.h>
37 const char* EMPTY_TAG = "(null)";
38 static bool gTraceManagerEnablePrintLog = false;
41 TraceManagerGeneric* TraceManagerGeneric::traceManagerGeneric = nullptr;
43 TraceManagerGeneric::TraceManagerGeneric(PerformanceInterface* performanceInterface)
44 : TraceManager(performanceInterface)
46 const char* enablePrintLog = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_TRACE_ENABLE_PRINT_LOG);
47 if(enablePrintLog && std::atoi(enablePrintLog) != 0)
49 gTraceManagerEnablePrintLog = true;
52 TraceManagerGeneric::traceManagerGeneric = this;
55 Dali::Integration::Trace::LogContextFunction TraceManagerGeneric::GetLogContextFunction()
60 void TraceManagerGeneric::LogContext(bool start, const char* tag, const char* message)
62 if(traceManagerGeneric && traceManagerGeneric->mPerformanceInterface)
66 unsigned short contextId = traceManagerGeneric->mPerformanceInterface->GetContextId(tag);
69 contextId = traceManagerGeneric->mPerformanceInterface->AddContext(tag);
71 traceManagerGeneric->mPerformanceInterface->AddMarker(PerformanceInterface::START, contextId);
75 unsigned short contextId = traceManagerGeneric->mPerformanceInterface->GetContextId(tag);
76 traceManagerGeneric->mPerformanceInterface->AddMarker(PerformanceInterface::END, contextId);
80 if(gTraceManagerEnablePrintLog)
84 DALI_LOG_DEBUG_INFO("BEGIN: %s%s%s\n", tag ? tag : EMPTY_TAG, message ? " " : "", message ? message : "");
88 DALI_LOG_DEBUG_INFO("END: %s%s%s\n", tag ? tag : EMPTY_TAG, message ? " " : "", message ? message : "");
93 } // namespace Adaptor
95 } // namespace Internal