• 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 HILOG_MODULE_H
17 #define HILOG_MODULE_H
18 
19 #include "hilog_string.h"
20 #include "hilog_vector.h"
21 #include "jsi/jsi.h"
22 #include "hilog_string.h"
23 #include "hilog_vector.h"
24 
25 namespace OHOS {
26 namespace ACELite {
27 typedef struct AddLogContentOutParams {
28     size_t *pos;
29     size_t *count;
30     HilogString *logContent;
31 } AddLogContentOutParams;
32 
33 class HilogModule {
34 public:
35     HilogModule() = default;
36     ~HilogModule() = default;
37     static JSIValue Debug(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
38     static JSIValue Info(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
39     static JSIValue Error(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
40     static JSIValue Warn(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
41     static JSIValue Fatal(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
42     static JSIValue IsLoggable(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum);
43 
44 private:
45     static JSIValue HilogImpl(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum, int level);
46     static bool HilogImplParseValue(
47         const JSIValue thisVal, const JSIValue *args, uint8_t argsNum, HilogVector *params);
48     static void ParseNapiValue(const JSIValue thisVal, const JSIValue *element, HilogVector *params);
49     static void ParseLogContent(const HilogString *formatStr, const HilogVector *params, HilogString *logContent);
50     static void AddLogContent(const char *format, const HilogVector *params, bool showPriv,
51         const AddLogContentOutParams *outParams);
52 };
53 } // namespace ACELite
54 } // namespace OHOS
55 
56 #endif // HILOG_MODULE_H