• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef HIVIEWDFX_HITRACECHAIN_CPP_H
17 #define HIVIEWDFX_HITRACECHAIN_CPP_H
18 
19 #include "hitrace/hitraceid.h"
20 
21 #ifdef __cplusplus
22 
23 #include <string>
24 
25 namespace OHOS {
26 namespace HiviewDFX {
27 class HiTraceChain final {
28 public:
29     static HiTraceId Begin(const std::string& name, int flags);
30     static void End(const HiTraceId& id);
31     static HiTraceId GetId();
32     static void SetId(const HiTraceId& id);
33     static void ClearId();
34     static HiTraceId CreateSpan();
35     static void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)
36         __attribute__((__format__(os_log, 3, 4)));
37     static void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id,
38         const char* fmt, ...) __attribute__((__format__(os_log, 4, 5)));
39 private:
40     HiTraceChain() = default;
41     ~HiTraceChain() = default;
42 };
43 } // namespace HiviewDFX
44 } // namespace OHOS
45 
46 #endif // __cplusplus
47 
48 #endif // HIVIEWDFX_HITRACECHAIN_CPP_H
49