DALi Version 2.2.7
[platform/core/uifw/dali-adaptor.git] / dali / internal / trace / tizen / trace-manager-impl-tizen.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/trace/tizen/trace-manager-impl-tizen.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <ttrace.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/environment-variable.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 namespace
35 {
36 const char* DALI_TRACE_ENABLE_PRINT_LOG_ENV = "DALI_TRACE_ENABLE_PRINT_LOG";
37 static bool gTraceManagerEnablePrintLog     = false;
38
39 } // namespace
40
41 TraceManagerTizen::TraceManagerTizen(PerformanceInterface* performanceInterface)
42 : TraceManager(performanceInterface)
43 {
44   const char* enablePrintLog = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_TRACE_ENABLE_PRINT_LOG_ENV);
45   if(enablePrintLog && std::atoi(enablePrintLog) != 0)
46   {
47     gTraceManagerEnablePrintLog = true;
48   }
49 }
50
51 Dali::Integration::Trace::LogContextFunction TraceManagerTizen::GetLogContextFunction()
52 {
53   return LogContext;
54 }
55
56 void TraceManagerTizen::LogContext(bool start, const char* tag)
57 {
58   if(start)
59   {
60     traceBegin(TTRACE_TAG_GRAPHICS, tag);
61
62     if(gTraceManagerEnablePrintLog)
63     {
64       DALI_LOG_DEBUG_INFO("BEGIN: %s\n", tag);
65     }
66   }
67   else
68   {
69     traceEnd(TTRACE_TAG_GRAPHICS);
70
71     if(gTraceManagerEnablePrintLog)
72     {
73       DALI_LOG_DEBUG_INFO("END: %s\n", tag);
74     }
75   }
76 }
77
78 } // namespace Adaptor
79
80 } // namespace Internal
81
82 } // namespace Dali