1 /*
2 * Copyright (c) 2023 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 #include "hilog_adapter.h"
17
18 #include "hilog/log.h"
19
20 namespace OHOS::NWeb {
21 namespace {
22 constexpr uint32_t NWEB_LOG_DOMAIN = 0xD004500;
23 const ::LogLevel LOG_LEVELS[] = {
24 LOG_DEBUG,
25 LOG_INFO,
26 LOG_WARN,
27 LOG_ERROR,
28 LOG_FATAL,
29 LOG_LEVEL_MAX,
30 };
31 } // namespace
32
33 extern "C" {
34 int HiLogPrintArgs(LogType type, LogLevel level, unsigned int domain, const char* tag, const char* fmt, va_list ap);
35 }
36
PrintLog(LogLevelAdapter level,const char * tag,const char * fmt,...)37 int HiLogAdapter::PrintLog(LogLevelAdapter level, const char* tag, const char* fmt, ...)
38 {
39 int ret;
40 va_list ap;
41 va_start(ap, fmt);
42 ret = HiLogPrintArgs(LOG_CORE, LOG_LEVELS[static_cast<uint32_t>(level)], NWEB_LOG_DOMAIN, tag, fmt, ap);
43 va_end(ap);
44 return ret;
45 }
46 } // namespace OHOS::NWeb
47