1 /* 2 * Copyright (C) 2021 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 OHOS_IPC_SERVICES_DBINDER_DBINDRR_LOG_H 17 #define OHOS_IPC_SERVICES_DBINDER_DBINDRR_LOG_H 18 19 #include "hilog/log.h" 20 #include "log_tags.h" 21 22 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, OHOS::LOG_ID_RPC_COMMON, LOG_TAG }; 23 24 #define DBINDER_LOGF(LOG_LABEL, fmt, args...) \ 25 if (HiLogIsLoggable(LOG_LABEL.domain, LOG_LABEL.tag, LOG_FATAL)) { \ 26 HILOG_IMPL(LOG_CORE, LOG_FATAL, LOG_LABEL.domain, LOG_LABEL.tag, \ 27 "%{public}s %{public}d: " fmt, __FUNCTION__, __LINE__, ##args); \ 28 } 29 30 #define DBINDER_LOGE(LOG_LABEL, fmt, args...) \ 31 if (HiLogIsLoggable(LOG_LABEL.domain, LOG_LABEL.tag, LOG_ERROR)) { \ 32 HILOG_IMPL(LOG_CORE, LOG_ERROR, LOG_LABEL.domain, LOG_LABEL.tag, \ 33 "%{public}s %{public}d: " fmt, __FUNCTION__, __LINE__, ##args); \ 34 } 35 36 #define DBINDER_LOGW(LOG_LABEL, fmt, args...) \ 37 if (HiLogIsLoggable(LOG_LABEL.domain, LOG_LABEL.tag, LOG_WARN)) { \ 38 HILOG_IMPL(LOG_CORE, LOG_WARN, LOG_LABEL.domain, LOG_LABEL.tag, \ 39 "%{public}s %{public}d: " fmt, __FUNCTION__, __LINE__, ##args); \ 40 } 41 42 #define DBINDER_LOGI(LOG_LABEL, fmt, args...) \ 43 if (HiLogIsLoggable(LOG_LABEL.domain, LOG_LABEL.tag, LOG_INFO)) { \ 44 HILOG_IMPL(LOG_CORE, LOG_INFO, LOG_LABEL.domain, LOG_LABEL.tag, \ 45 "%{public}s %{public}d: " fmt, __FUNCTION__, __LINE__, ##args); \ 46 } 47 48 #define DBINDER_LOGD(LOG_LABEL, fmt, args...) \ 49 if (HiLogIsLoggable(LOG_LABEL.domain, LOG_LABEL.tag, LOG_DEBUG)) { \ 50 HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_LABEL.domain, LOG_LABEL.tag, \ 51 "%{public}s %{public}d: " fmt, __FUNCTION__, __LINE__, ##args); \ 52 } 53 54 #endif // OHOS_IPC_SERVICES_DBINDER_DBINDRR_LOG_H 55