1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "base/log/ace_trace.h"
17
18 namespace OHOS::Ace {
AceTraceEnabled()19 bool AceTraceEnabled()
20 {
21 return false;
22 }
23
AceTraceBegin(const char * name)24 void AceTraceBegin(const char* name) {}
25
AceTraceEnd()26 void AceTraceEnd() {}
27
AceAsyncTraceBegin(int32_t taskId,const char * name,bool isAnimationTrace)28 void AceAsyncTraceBegin(int32_t taskId, const char* name, bool isAnimationTrace) {}
29
AceAsyncTraceEnd(int32_t taskId,const char * name,bool isAnimationTrace)30 void AceAsyncTraceEnd(int32_t taskId, const char* name, bool isAnimationTrace) {}
31
AceCountTrace(const char * key,int32_t count)32 void AceCountTrace(const char* key, int32_t count) {}
33
AceTraceBeginWithArgv(const char *,va_list)34 bool AceTraceBeginWithArgv(const char* /* format */, va_list /* args */)
35 {
36 return false;
37 }
38
AceTraceBeginWithArgs(const char *,...)39 bool AceTraceBeginWithArgs(const char* /* format */, ...)
40 {
41 return false;
42 }
43
AceCountTraceWidthArgs(int32_t count,const char * format,...)44 void AceCountTraceWidthArgs(int32_t count, const char* format, ...) {}
45
AceScopedTrace(const char *,...)46 AceScopedTrace::AceScopedTrace(const char* /* format */, ...) : traceEnabled_(AceTraceEnabled()) {}
47
48 AceScopedTrace::~AceScopedTrace() = default;
49
AceScopedTraceFlag(bool,const char *,...)50 AceScopedTraceFlag::AceScopedTraceFlag(bool /* flag */, const char* /* format */, ...) {}
51
~AceScopedTraceFlag()52 AceScopedTraceFlag::~AceScopedTraceFlag()
53 {
54 if (flagTraceEnabled_) {
55 AceTraceEnd();
56 }
57 }
58
AceAsyncTraceBeginWithArgv(int32_t,const char *,va_list)59 std::string ACE_EXPORT AceAsyncTraceBeginWithArgv(int32_t /* taskId */, const char* /* format */, va_list /* args */)
60 {
61 return {};
62 }
63
AceAsyncTraceBeginWithArgs(int32_t,char *,...)64 std::string ACE_EXPORT AceAsyncTraceBeginWithArgs(int32_t /* taskId */, char* /* format */, ...)
65 {
66 return {};
67 }
68
69 std::atomic<std::int32_t> AceAsyncScopedTrace::id_ = 0;
70
AceAsyncScopedTrace(const char *,...)71 AceAsyncScopedTrace::AceAsyncScopedTrace(const char* /* format */, ...)
72 {
73 id_++;
74 if (asyncTraceEnabled_) {
75 taskId_ = id_;
76 }
77 }
78
79 AceAsyncScopedTrace::~AceAsyncScopedTrace() = default;
80 } // namespace OHOS::Ace
81