• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SANDBOXMANAGER_LOG_H
17 #define SANDBOXMANAGER_LOG_H
18 
19 #include <string>
20 namespace OHOS {
21 namespace AccessControl {
22 namespace SandboxManager {
23 
24 class SandboxManagerLog {
25 public:
26     static std::string MaskRealPath(const char *path);
27 };
28 } // namespace SandboxManager
29 } // namespace AccessControl
30 } // namespace OHOS
31 
32 #ifdef HILOG_ENABLE
33 
34 #include "hilog/log.h"
35 
36 /* define LOG_TAG as "accesscontrol_*" at your submodule, * means your submodule name such as "accesscontrol__dac" */
37 #undef LOG_TAG
38 #undef LOG_DOMAIN
39 static constexpr unsigned int ACCESSCONTROL_DOMAIN_SANDBOXMANAGER = 0xD005A07;
40 
41 #define SANDBOXMANAGER_LOG_DEBUG(label, fmt, ...) \
42     ((void)HILOG_IMPL(label.type, LOG_DEBUG, label.domain, label.tag, \
43     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
44 #define SANDBOXMANAGER_LOG_INFO(label, fmt, ...) \
45     ((void)HILOG_IMPL(label.type, LOG_INFO, label.domain, label.tag, \
46     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
47 #define SANDBOXMANAGER_LOG_WARN(label, fmt, ...) \
48     ((void)HILOG_IMPL(label.type, LOG_WARN, label.domain, label.tag, \
49     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
50 #define SANDBOXMANAGER_LOG_ERROR(label, fmt, ...) \
51     ((void)HILOG_IMPL(label.type, LOG_ERROR, label.domain, label.tag, \
52     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
53 #define SANDBOXMANAGER_LOG_FATAL(label, fmt, ...) \
54     ((void)HILOG_IMPL(label.type, LOG_FATAL, label.domain, label.tag, \
55     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
56 
57 #else
58 
59 #include <stdarg.h>
60 #include <stdio.h>
61 
62 /* define LOG_TAG as "accesscontrol__*" at your submodule, * means your submodule name such as "accesscontrol__dac" */
63 #undef LOG_TAG
64 
65 #define SANDBOXMANAGER_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
66 #define SANDBOXMANAGER_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
67 #define SANDBOXMANAGER_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
68 #define SANDBOXMANAGER_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
69 #define SANDBOXMANAGER_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
70 
71 #endif // HILOG_ENABLE
72 
73 #endif // SANDBOXMANAGER_LOG_H
74