• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 HILOG_ANI_BASE_H
17 #define HILOG_ANI_BASE_H
18 
19 #include <ani.h>
20 #include "ani_util.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 using AniParam = struct {
25     AniArgsType type;
26     std::string val;
27 };
28 
29 typedef struct LogContentPosition {
30     uint32_t pos = 0;
31     uint32_t count = 0;
32 } LogContentPosition;
33 
34 class HilogAniBase {
35 public:
36     static void Debug(ani_env *env, ani_double domain, ani_string tag, ani_string format, ani_array args);
37     static void HilogImpl(ani_env *env, ani_double domain, ani_string tag, ani_string format, ani_array args,
38                           int level, bool isAppLog);
39     static void Info(ani_env *env, ani_double domain, ani_string tag, ani_string format, ani_array args);
40     static void Warn(ani_env *env, ani_double domain, ani_string tag, ani_string format, ani_array args);
41     static void Error(ani_env *env, ani_double domain, ani_string tag, ani_string format, ani_array args);
42     static void Fatal(ani_env *env, ani_double domain, ani_string tag, ani_string format, ani_array args);
43     static ani_boolean IsLoggable(ani_env *env, ani_double domain, ani_string tag, ani_enum_item level);
44     static void SetMinLogLevel(ani_env *env, ani_enum_item level);
45 
46 private:
47     static void ParseAniValue(ani_env *env, ani_ref element, std::vector<AniParam> &params);
48 };
49 }  // namespace HiviewDFX
50 }  // namespace OHOS
51 
52 #endif //HILOG_ANI_BASE_H
53