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 #ifdef HILOG_ENABLE
20 
21 #include "hilog/log.h"
22 
23 /* define LOG_TAG as "accesscontrol_*" at your submodule, * means your submodule name such as "accesscontrol__dac" */
24 #undef LOG_TAG
25 #undef LOG_DOMAIN
26 static constexpr unsigned int ACCESSCONTROL_DOMAIN_SANDBOXMANAGER = 0xD005A07;
27 
28 #define SANDBOXMANAGER_LOG_DEBUG(label, fmt, ...) \
29     ((void)HILOG_IMPL(label.type, LOG_DEBUG, label.domain, label.tag, \
30     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
31 #define SANDBOXMANAGER_LOG_INFO(label, fmt, ...) \
32     ((void)HILOG_IMPL(label.type, LOG_INFO, label.domain, label.tag, \
33     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
34 #define SANDBOXMANAGER_LOG_WARN(label, fmt, ...) \
35     ((void)HILOG_IMPL(label.type, LOG_WARN, label.domain, label.tag, \
36     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
37 #define SANDBOXMANAGER_LOG_ERROR(label, fmt, ...) \
38     ((void)HILOG_IMPL(label.type, LOG_ERROR, label.domain, label.tag, \
39     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
40 #define SANDBOXMANAGER_LOG_FATAL(label, fmt, ...) \
41     ((void)HILOG_IMPL(label.type, LOG_FATAL, label.domain, label.tag, \
42     "[%{public}s]" fmt, __FUNCTION__, ##__VA_ARGS__))
43 
44 #else
45 
46 #include <stdarg.h>
47 #include <stdio.h>
48 
49 /* define LOG_TAG as "accesscontrol__*" at your submodule, * means your submodule name such as "accesscontrol__dac" */
50 #undef LOG_TAG
51 
52 #define SANDBOXMANAGER_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
53 #define SANDBOXMANAGER_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
54 #define SANDBOXMANAGER_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
55 #define SANDBOXMANAGER_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
56 #define SANDBOXMANAGER_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
57 
58 #endif // HILOG_ENABLE
59 
60 #endif // SANDBOXMANAGER_LOG_H
61