195489c19Sopenharmony_ci/*
295489c19Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
395489c19Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
495489c19Sopenharmony_ci * you may not use this file except in compliance with the License.
595489c19Sopenharmony_ci * You may obtain a copy of the License at
695489c19Sopenharmony_ci *
795489c19Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
895489c19Sopenharmony_ci *
995489c19Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1095489c19Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1195489c19Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1295489c19Sopenharmony_ci * See the License for the specific language governing permissions and
1395489c19Sopenharmony_ci * limitations under the License.
1495489c19Sopenharmony_ci */
1595489c19Sopenharmony_ci
1695489c19Sopenharmony_ci#ifndef BLUETOOTH_LOG_H
1795489c19Sopenharmony_ci#define BLUETOOTH_LOG_H
1895489c19Sopenharmony_ci
1995489c19Sopenharmony_ci#undef LOG_DOMAIN
2095489c19Sopenharmony_ci#define LOG_DOMAIN 0xD000101
2195489c19Sopenharmony_ci#ifndef LOG_TAG
2295489c19Sopenharmony_ci#define LOG_TAG "Bluetooth"
2395489c19Sopenharmony_ci#endif
2495489c19Sopenharmony_ci
2595489c19Sopenharmony_ci#include "hilog/log.h"
2695489c19Sopenharmony_ci
2795489c19Sopenharmony_ci#ifdef HILOGF
2895489c19Sopenharmony_ci#undef HILOGF
2995489c19Sopenharmony_ci#endif
3095489c19Sopenharmony_ci
3195489c19Sopenharmony_ci#ifdef HILOGE
3295489c19Sopenharmony_ci#undef HILOGE
3395489c19Sopenharmony_ci#endif
3495489c19Sopenharmony_ci
3595489c19Sopenharmony_ci#ifdef HILOGW
3695489c19Sopenharmony_ci#undef HILOGW
3795489c19Sopenharmony_ci#endif
3895489c19Sopenharmony_ci
3995489c19Sopenharmony_ci#ifdef HILOGI
4095489c19Sopenharmony_ci#undef HILOGI
4195489c19Sopenharmony_ci#endif
4295489c19Sopenharmony_ci
4395489c19Sopenharmony_ci#ifdef HILOGD
4495489c19Sopenharmony_ci#undef HILOGD
4595489c19Sopenharmony_ci#endif
4695489c19Sopenharmony_ci
4795489c19Sopenharmony_ci#define HILOGD(fmt, ...)                 \
4895489c19Sopenharmony_ci    HILOG_DEBUG(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt,    \
4995489c19Sopenharmony_ci        __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
5095489c19Sopenharmony_ci#define HILOGI(fmt, ...)                \
5195489c19Sopenharmony_ci    HILOG_INFO(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt,    \
5295489c19Sopenharmony_ci        __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
5395489c19Sopenharmony_ci#define HILOGW(fmt, ...)                \
5495489c19Sopenharmony_ci    HILOG_WARN(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt,    \
5595489c19Sopenharmony_ci        __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
5695489c19Sopenharmony_ci#define HILOGE(fmt, ...)                 \
5795489c19Sopenharmony_ci    HILOG_ERROR(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt,    \
5895489c19Sopenharmony_ci        __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
5995489c19Sopenharmony_ci#define HILOGF(fmt, ...)                 \
6095489c19Sopenharmony_ci    HILOG_FATAL(LOG_CORE, "[%{public}s(%{public}s:%{public}d)]" fmt,    \
6195489c19Sopenharmony_ci        __FILE_NAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
6295489c19Sopenharmony_ci
6395489c19Sopenharmony_ci#ifdef CHECK_AND_RETURN_LOG
6495489c19Sopenharmony_ci#undef CHECK_AND_RETURN_LOG
6595489c19Sopenharmony_ci#endif
6695489c19Sopenharmony_ci
6795489c19Sopenharmony_ci#define CHECK_AND_RETURN_LOG(cond, fmt, ...)        \
6895489c19Sopenharmony_ci    do {                                            \
6995489c19Sopenharmony_ci        if (!(cond)) {                              \
7095489c19Sopenharmony_ci            HILOGE(fmt, ##__VA_ARGS__);             \
7195489c19Sopenharmony_ci            return;                                 \
7295489c19Sopenharmony_ci        }                                           \
7395489c19Sopenharmony_ci    } while (0)
7495489c19Sopenharmony_ci
7595489c19Sopenharmony_ci#ifdef CHECK_AND_RETURN_LOG_RET
7695489c19Sopenharmony_ci#undef CHECK_AND_RETURN_LOG_RET
7795489c19Sopenharmony_ci#endif
7895489c19Sopenharmony_ci
7995489c19Sopenharmony_ci#define CHECK_AND_RETURN_LOG_RET(cond, ret, fmt, ...)               \
8095489c19Sopenharmony_ci    do {                                                            \
8195489c19Sopenharmony_ci        if (!(cond)) {                                              \
8295489c19Sopenharmony_ci            HILOGE(fmt, ##__VA_ARGS__);                             \
8395489c19Sopenharmony_ci            return ret;                                             \
8495489c19Sopenharmony_ci        }                                                           \
8595489c19Sopenharmony_ci    } while (0)
8695489c19Sopenharmony_ci
8795489c19Sopenharmony_ci#endif  // BLUETOOTH_LOG_H
88