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 <time.h> 44 #include "common_util.h" 45 46 #define LOG_DEBUG "Debug" 47 #define LOG_TRACE "Trace" 48 #define LOG_WARN "Warn" 49 #define LOG_ERROR "Error" 50 #define LOG_INFO "Info" 51 52 #define DEBUG_MODE 1 53 54 #define LOG_TAG "DhcpServer" 55 56 #define LOGD(log, ...) \ 57 do { \ 58 LogTime(); \ 59 printf(" %s] %s ", LOG_DEBUG, LOG_TAG); \ 60 printf((log), ##__VA_ARGS__); \ 61 printf("(line:%d)\n", __LINE__); \ 62 } while (0); 63 64 #define LOGW(log, ...) \ 65 do { \ 66 LogTime(); \ 67 printf(" %s] %s ", LOG_WARN, LOG_TAG); \ 68 printf((log), ##__VA_ARGS__); \ 69 printf("\n"); \ 70 } while (0); 71 72 #define LOGE(log, ...) \ 73 do { \ 74 LogTime(); \ 75 printf(" %s] %s ", LOG_ERROR, LOG_TAG); \ 76 printf((log), ##__VA_ARGS__); \ 77 printf("(line:%d)\n", __LINE__); \ 78 } while (0); 79 80 #define LOGI(log, ...) \ 81 do { \ 82 LogTime(); \ 83 printf(" %s] %s ", LOG_INFO, LOG_TAG); \ 84 printf((log), ##__VA_ARGS__); \ 85 printf("\n"); \ 86 } while (0); 87 88 #endif // DHCP_HILOG_ENABLE 89 #endif 90