1/* 2 * Copyright (c) 2020 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 <cstdarg> 17#include <cstdio> 18 19#include "hilog_cp.h" 20 21namespace OHOS { 22namespace HiviewDFX { 23#define HILOG_VA_ARGS_PRORESS(ret, level) \ 24 do { \ 25 va_list args; \ 26 va_start(args, fmt); \ 27 (ret) = ::HiLogPrintArgs(label.type, (level), label.domain, label.tag, fmt, args); \ 28 va_end(args); \ 29 } while (0) 30 31int HiLog::Debug(const HiLogLabel &label, const char *fmt, ...) 32{ 33 int ret; 34 HILOG_VA_ARGS_PRORESS(ret, LOG_DEBUG); 35 return ret; 36} 37 38int HiLog::Info(const HiLogLabel &label, const char *fmt, ...) 39{ 40 int ret; 41 HILOG_VA_ARGS_PRORESS(ret, LOG_INFO); 42 return ret; 43} 44 45int HiLog::Warn(const HiLogLabel &label, const char *fmt, ...) 46{ 47 int ret; 48 HILOG_VA_ARGS_PRORESS(ret, LOG_WARN); 49 return ret; 50} 51 52int HiLog::Error(const HiLogLabel &label, const char *fmt, ...) 53{ 54 int ret; 55 HILOG_VA_ARGS_PRORESS(ret, LOG_ERROR); 56 return ret; 57} 58 59int HiLog::Fatal(const HiLogLabel &label, const char *fmt, ...) 60{ 61 int ret; 62 HILOG_VA_ARGS_PRORESS(ret, LOG_FATAL); 63 return ret; 64} 65} // namespace HiviewDFX 66} // namespace OHOS 67