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