12498b56bSopenharmony_ci/*
22498b56bSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
32498b56bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
42498b56bSopenharmony_ci * you may not use this file except in compliance with the License.
52498b56bSopenharmony_ci * You may obtain a copy of the License at
62498b56bSopenharmony_ci *
72498b56bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
82498b56bSopenharmony_ci *
92498b56bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
102498b56bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
112498b56bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122498b56bSopenharmony_ci * See the License for the specific language governing permissions and
132498b56bSopenharmony_ci * limitations under the License.
142498b56bSopenharmony_ci */
152498b56bSopenharmony_ci
162498b56bSopenharmony_ci#include "hilog/log.h"
172498b56bSopenharmony_ci#include "hilog_inner.h"
182498b56bSopenharmony_ci
192498b56bSopenharmony_ci#include <cstdarg>
202498b56bSopenharmony_ci#include <cstdio>
212498b56bSopenharmony_ci
222498b56bSopenharmony_cinamespace OHOS {
232498b56bSopenharmony_cinamespace HiviewDFX {
242498b56bSopenharmony_ci#define HILOG_VA_ARGS_PROCESS(ret, level) \
252498b56bSopenharmony_ci    do { \
262498b56bSopenharmony_ci        va_list args; \
272498b56bSopenharmony_ci        va_start(args, fmt); \
282498b56bSopenharmony_ci        (ret) = ::HiLogPrintArgs(label.type, (level), label.domain, label.tag, fmt, args); \
292498b56bSopenharmony_ci        va_end(args); \
302498b56bSopenharmony_ci    } while (0)
312498b56bSopenharmony_ci
322498b56bSopenharmony_ciint HiLog::Debug(const HiLogLabel &label, const char *fmt, ...)
332498b56bSopenharmony_ci{
342498b56bSopenharmony_ci    int ret;
352498b56bSopenharmony_ci    HILOG_VA_ARGS_PROCESS(ret, LOG_DEBUG);
362498b56bSopenharmony_ci    return ret;
372498b56bSopenharmony_ci}
382498b56bSopenharmony_ci
392498b56bSopenharmony_ciint HiLog::Info(const HiLogLabel &label, const char *fmt, ...)
402498b56bSopenharmony_ci{
412498b56bSopenharmony_ci    int ret;
422498b56bSopenharmony_ci    HILOG_VA_ARGS_PROCESS(ret, LOG_INFO);
432498b56bSopenharmony_ci    return ret;
442498b56bSopenharmony_ci}
452498b56bSopenharmony_ci
462498b56bSopenharmony_ciint HiLog::Warn(const HiLogLabel &label, const char *fmt, ...)
472498b56bSopenharmony_ci{
482498b56bSopenharmony_ci    int ret;
492498b56bSopenharmony_ci    HILOG_VA_ARGS_PROCESS(ret, LOG_WARN);
502498b56bSopenharmony_ci    return ret;
512498b56bSopenharmony_ci}
522498b56bSopenharmony_ci
532498b56bSopenharmony_ciint HiLog::Error(const HiLogLabel &label, const char *fmt, ...)
542498b56bSopenharmony_ci{
552498b56bSopenharmony_ci    int ret;
562498b56bSopenharmony_ci    HILOG_VA_ARGS_PROCESS(ret, LOG_ERROR);
572498b56bSopenharmony_ci    return ret;
582498b56bSopenharmony_ci}
592498b56bSopenharmony_ci
602498b56bSopenharmony_ciint HiLog::Fatal(const HiLogLabel &label, const char *fmt, ...)
612498b56bSopenharmony_ci{
622498b56bSopenharmony_ci    int ret;
632498b56bSopenharmony_ci    HILOG_VA_ARGS_PROCESS(ret, LOG_FATAL);
642498b56bSopenharmony_ci    return ret;
652498b56bSopenharmony_ci}
662498b56bSopenharmony_ci} // namespace HiviewDFX
672498b56bSopenharmony_ci} // namespace OHOS
68