1e66f31c5Sopenharmony_ci/* 2e66f31c5Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3e66f31c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e66f31c5Sopenharmony_ci * you may not use this file except in compliance with the License. 5e66f31c5Sopenharmony_ci * You may obtain a copy of the License at 6e66f31c5Sopenharmony_ci * 7e66f31c5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e66f31c5Sopenharmony_ci * 9e66f31c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e66f31c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e66f31c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e66f31c5Sopenharmony_ci * See the License for the specific language governing permissions and 13e66f31c5Sopenharmony_ci * limitations under the License. 14e66f31c5Sopenharmony_ci */ 15e66f31c5Sopenharmony_ci 16e66f31c5Sopenharmony_ci#include "uv_log.h" 17e66f31c5Sopenharmony_ci#include "hilog/log.h" 18e66f31c5Sopenharmony_ci 19e66f31c5Sopenharmony_ci#include <stdarg.h> 20e66f31c5Sopenharmony_ci 21e66f31c5Sopenharmony_ciextern int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, 22e66f31c5Sopenharmony_ci const char *fmt, va_list ap); 23e66f31c5Sopenharmony_ci 24e66f31c5Sopenharmony_ciLogLevel convert_uv_log_level(enum uv__log_level level) { 25e66f31c5Sopenharmony_ci switch (level) 26e66f31c5Sopenharmony_ci { 27e66f31c5Sopenharmony_ci case UV_DEBUG: 28e66f31c5Sopenharmony_ci return LOG_DEBUG; 29e66f31c5Sopenharmony_ci case UV_INFO: 30e66f31c5Sopenharmony_ci return LOG_INFO; 31e66f31c5Sopenharmony_ci case UV_WARN: 32e66f31c5Sopenharmony_ci return LOG_WARN; 33e66f31c5Sopenharmony_ci case UV_ERROR: 34e66f31c5Sopenharmony_ci return LOG_ERROR; 35e66f31c5Sopenharmony_ci case UV_FATAL: 36e66f31c5Sopenharmony_ci return LOG_FATAL; 37e66f31c5Sopenharmony_ci default: 38e66f31c5Sopenharmony_ci return LOG_LEVEL_MIN; 39e66f31c5Sopenharmony_ci } 40e66f31c5Sopenharmony_ci} 41e66f31c5Sopenharmony_ci 42e66f31c5Sopenharmony_ciint uv__log_impl(enum uv__log_level level, const char *fmt, ...) { 43e66f31c5Sopenharmony_ci va_list args; 44e66f31c5Sopenharmony_ci va_start(args, fmt); 45e66f31c5Sopenharmony_ci int ret = HiLogPrintArgs(LOG_CORE, convert_uv_log_level(level), 0xD003301, "LIBUV", fmt, args); 46e66f31c5Sopenharmony_ci va_end(args); 47e66f31c5Sopenharmony_ci return ret; 48e66f31c5Sopenharmony_ci} 49