1 /* 2 * Copyright (c) 2024 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 UV_LOG_H 17 #define UV_LOG_H 18 19 #ifdef USE_OHOS_DFX 20 #include "hilog/log.h" 21 #define UV_LOGI(fmt, ...) HILOG_IMPL(LOG_CORE, LOG_INFO, 0xD003301, "LIBUV", fmt, ##__VA_ARGS__) 22 #define UV_LOGD(fmt, ...) HILOG_IMPL(LOG_CORE, LOG_DEBUG, 0xD003301, "LIBUV", fmt, ##__VA_ARGS__) 23 #define UV_LOGW(fmt, ...) HILOG_IMPL(LOG_CORE, LOG_WARN, 0xD003301, "LIBUV", fmt, ##__VA_ARGS__) 24 #define UV_LOGE(fmt, ...) HILOG_IMPL(LOG_CORE, LOG_ERROR, 0xD003301, "LIBUV", fmt, ##__VA_ARGS__) 25 #define UV_LOGF(fmt, ...) HILOG_IMPL(LOG_CORE, LOG_FATAL, 0xD003301, "LIBUV", fmt, ##__VA_ARGS__) 26 #else 27 enum uv__log_level { 28 UV_MIN = 0, 29 UV_DEBUG = 3, 30 UV_INFO, 31 UV_WARN, 32 UV_ERROR, 33 UV_FATAL, 34 UV_MAX, 35 }; 36 37 extern int uv__log_impl(enum uv__log_level level, const char* fmt, ...); 38 39 #define UV_LOGI(...) LOGI_IMPL(UV_INFO, ##__VA_ARGS__) 40 #define UV_LOGD(...) LOGI_IMPL(UV_DEBUG, ##__VA_ARGS__) 41 #define UV_LOGW(...) LOGI_IMPL(UV_WARN, ##__VA_ARGS__) 42 #define UV_LOGE(...) LOGI_IMPL(UV_ERROR, ##__VA_ARGS__) 43 #define UV_LOGF(...) LOGI_IMPL(UV_FATAL, ##__VA_ARGS__) 44 45 #define LOGI_IMPL(level, ...) uv__log_impl(level, ##__VA_ARGS__) 46 #endif 47 48 #endif 49