106694b06Sopenharmony_ci/*
206694b06Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
306694b06Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
406694b06Sopenharmony_ci * you may not use this file except in compliance with the License.
506694b06Sopenharmony_ci * You may obtain a copy of the License at
606694b06Sopenharmony_ci *
706694b06Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
806694b06Sopenharmony_ci *
906694b06Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1006694b06Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1106694b06Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1206694b06Sopenharmony_ci * See the License for the specific language governing permissions and
1306694b06Sopenharmony_ci * limitations under the License.
1406694b06Sopenharmony_ci */
1506694b06Sopenharmony_ci
1606694b06Sopenharmony_ci#ifndef RDB_LOGGER_H
1706694b06Sopenharmony_ci#define RDB_LOGGER_H
1806694b06Sopenharmony_ci
1906694b06Sopenharmony_ci#include "hilog/log.h"
2006694b06Sopenharmony_ci
2106694b06Sopenharmony_cinamespace OHOS {
2206694b06Sopenharmony_cinamespace Rdb {
2306694b06Sopenharmony_cistatic inline OHOS::HiviewDFX::HiLogLabel LogLabel()
2406694b06Sopenharmony_ci{
2506694b06Sopenharmony_ci    return { LOG_CORE, 0xD001650, "Rdb" };
2606694b06Sopenharmony_ci}
2706694b06Sopenharmony_ci} // namespace Rdb
2806694b06Sopenharmony_ci
2906694b06Sopenharmony_cinamespace RdbNdk {
3006694b06Sopenharmony_cistatic inline OHOS::HiviewDFX::HiLogLabel LogLabel()
3106694b06Sopenharmony_ci{
3206694b06Sopenharmony_ci    return { LOG_CORE, 0xD001656, "RdbNdk" };
3306694b06Sopenharmony_ci}
3406694b06Sopenharmony_ci} // namespace RdbNdk
3506694b06Sopenharmony_ci
3606694b06Sopenharmony_cinamespace SendableRdb {
3706694b06Sopenharmony_cistatic inline OHOS::HiviewDFX::HiLogLabel LogLabel()
3806694b06Sopenharmony_ci{
3906694b06Sopenharmony_ci    return { LOG_CORE, 0xD001650, "SRdb" };
4006694b06Sopenharmony_ci}
4106694b06Sopenharmony_ci} // namespace Rdb
4206694b06Sopenharmony_ci} // namespace OHOS
4306694b06Sopenharmony_ci
4406694b06Sopenharmony_ci#define LOG_DEBUG(fmt, ...)                                                    \
4506694b06Sopenharmony_ci    do {                                                                       \
4606694b06Sopenharmony_ci        auto lable = LogLabel();                                               \
4706694b06Sopenharmony_ci        if (HiLogIsLoggable(lable.domain, lable.tag, LogLevel::LOG_DEBUG)) {   \
4806694b06Sopenharmony_ci            ((void)HILOG_IMPL(lable.type, LOG_DEBUG, lable.domain, lable.tag,  \
4906694b06Sopenharmony_ci                LOG_TAG "[%{public}s]: " fmt, __FUNCTION__, ##__VA_ARGS__));   \
5006694b06Sopenharmony_ci        }                                                                      \
5106694b06Sopenharmony_ci    } while (0)
5206694b06Sopenharmony_ci
5306694b06Sopenharmony_ci#define LOG_INFO(fmt, ...)                                                     \
5406694b06Sopenharmony_ci    do {                                                                       \
5506694b06Sopenharmony_ci        auto lable = LogLabel();                                               \
5606694b06Sopenharmony_ci        if (HiLogIsLoggable(lable.domain, lable.tag, LogLevel::LOG_INFO)) {    \
5706694b06Sopenharmony_ci            ((void)HILOG_IMPL(lable.type, LOG_INFO, lable.domain, lable.tag,   \
5806694b06Sopenharmony_ci                LOG_TAG "[%{public}s]: " fmt, __FUNCTION__, ##__VA_ARGS__));    \
5906694b06Sopenharmony_ci        }                                                                      \
6006694b06Sopenharmony_ci    } while (0)
6106694b06Sopenharmony_ci
6206694b06Sopenharmony_ci#define LOG_WARN(fmt, ...)                                                     \
6306694b06Sopenharmony_ci    do {                                                                       \
6406694b06Sopenharmony_ci        auto lable = LogLabel();                                               \
6506694b06Sopenharmony_ci        if (HiLogIsLoggable(lable.domain, lable.tag, LogLevel::LOG_WARN)) {    \
6606694b06Sopenharmony_ci            ((void)HILOG_IMPL(lable.type, LOG_WARN, lable.domain, lable.tag,   \
6706694b06Sopenharmony_ci                LOG_TAG "[%{public}s]: " fmt, __FUNCTION__, ##__VA_ARGS__));    \
6806694b06Sopenharmony_ci        }                                                                      \
6906694b06Sopenharmony_ci    } while (0)
7006694b06Sopenharmony_ci
7106694b06Sopenharmony_ci#define LOG_ERROR(fmt, ...)                                                    \
7206694b06Sopenharmony_ci    do {                                                                       \
7306694b06Sopenharmony_ci        auto lable = LogLabel();                                               \
7406694b06Sopenharmony_ci        if (HiLogIsLoggable(lable.domain, lable.tag, LogLevel::LOG_ERROR)) {   \
7506694b06Sopenharmony_ci            ((void)HILOG_IMPL(lable.type, LOG_ERROR, lable.domain, lable.tag,  \
7606694b06Sopenharmony_ci                LOG_TAG "[%{public}s]: " fmt, __FUNCTION__, ##__VA_ARGS__));   \
7706694b06Sopenharmony_ci        }                                                                      \
7806694b06Sopenharmony_ci    } while (0)
7906694b06Sopenharmony_ci
8006694b06Sopenharmony_ci#define LOG_FATAL(fmt, ...)                                                    \
8106694b06Sopenharmony_ci    do {                                                                       \
8206694b06Sopenharmony_ci        auto lable = LogLabel();                                               \
8306694b06Sopenharmony_ci        if (HiLogIsLoggable(lable.domain, lable.tag, LogLevel::LOG_FATAL)) {   \
8406694b06Sopenharmony_ci            ((void)HILOG_IMPL(lable.type, LOG_FATAL, lable.domain, lable.tag,  \
8506694b06Sopenharmony_ci                LOG_TAG "[%{public}s]: " fmt, __FUNCTION__, ##__VA_ARGS__));   \
8606694b06Sopenharmony_ci        }                                                                      \
8706694b06Sopenharmony_ci    } while (0)
8806694b06Sopenharmony_ci
8906694b06Sopenharmony_ci#endif // RDB_LOGGER_H
90