1 /* 2 * Copyright (C) 2021-2022 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_DHCP_LOGGER_H 17 #define OHOS_DHCP_LOGGER_H 18 19 #ifdef DHCP_HILOG_ENABLE 20 #ifdef OHOS_ARCH_LITE 21 #include "hilog/log.h" 22 #else 23 #include "hilog/log_c.h" 24 #endif 25 26 #undef LOG_TAG 27 #define LOG_TAG "DhcpServer" 28 29 #undef LOG_DOMAIN 30 #define LOG_DOMAIN 0xD001560 31 32 #define LOGD(...) ((void)HiLogPrint(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) 33 34 #define LOGI(...) ((void)HiLogPrint(LOG_CORE, LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) 35 36 #define LOGW(...) ((void)HiLogPrint(LOG_CORE, LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) 37 38 #define LOGE(...) ((void)HiLogPrint(LOG_CORE, LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) 39 40 #define LOGF(...) ((void)HiLogPrint(LOG_CORE, LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) 41 #else 42 #include <stdio.h> 43 #include "common_util.h" 44 45 #define LOG_DEBUG "Debug" 46 #define LOG_TRACE "Trace" 47 #define LOG_WARN "Warn" 48 #define LOG_ERROR "Error" 49 #define LOG_INFO "Info" 50 51 #define DEBUG_MODE 1 52 53 #define LOG_TAG "DhcpServer" 54 55 #define LOGD(log, ...) \ 56 do { \ 57 LogTime(); \ 58 printf(" %s] %s ", LOG_DEBUG, LOG_TAG); \ 59 printf((log), ##__VA_ARGS__); \ 60 printf("(line:%d)\n", __LINE__); \ 61 } while (0) 62 63 #define LOGW(log, ...) \ 64 do { \ 65 LogTime(); \ 66 printf(" %s] %s ", LOG_WARN, LOG_TAG); \ 67 printf((log), ##__VA_ARGS__); \ 68 printf("\n"); \ 69 } while (0) 70 71 #define LOGE(log, ...) \ 72 do { \ 73 LogTime(); \ 74 printf(" %s] %s ", LOG_ERROR, LOG_TAG); \ 75 printf((log), ##__VA_ARGS__); \ 76 printf("(line:%d)\n", __LINE__); \ 77 } while (0) 78 79 #define LOGI(log, ...) \ 80 do { \ 81 LogTime(); \ 82 printf(" %s] %s ", LOG_INFO, LOG_TAG); \ 83 printf((log), ##__VA_ARGS__); \ 84 printf("\n"); \ 85 } while (0) 86 87 #endif // DHCP_HILOG_ENABLE 88 #endif 89