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_mock.h"
17
18 namespace {
19 constexpr int32_t ARG_COUNT = 1;
20 }
21
HiLogPrint(LogType type,LogLevel level,unsigned int domain,const char * tag,const char * fmt,...)22 int32_t HilogMock::HiLogPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...)
23 {
24 return 0;
25 }
26
HilogMock()27 HilogMock::HilogMock()
28 {
29 mock.store(this);
30 }
~HilogMock()31 HilogMock::~HilogMock()
32 {
33 mock.store(nullptr);
34 }
35
HiLogPrint(LogType type,LogLevel level,unsigned int domain,const char * tag,const char * fmt,...)36 int32_t HiLogPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...)
37 {
38 char *args;
39 va_list va_args;
40 va_start(va_args, fmt);
41 for (int32_t i = 0; i < ARG_COUNT; ++i) {
42 args = va_arg(va_args, char *);
43 }
44 va_end(va_args);
45 return HilogMock::GetMock()->HiLogPrint(type, level, domain, tag, fmt, args);
46 }
47
48 #ifdef HILOG_RAWFORMAT
HiLogPrintDictNew(const LogType type,const LogLevel level,const unsigned int domain,const char * tag,const unsigned int uuid,const unsigned int fmtOffset,const char * fmt,...)49 int32_t HiLogPrintDictNew(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
50 const unsigned int uuid, const unsigned int fmtOffset, const char *fmt, ...)
51 {
52 (void)uuid;
53 (void)fmtOffset;
54 char *args;
55 va_list va_args;
56 va_start(va_args, fmt);
57 for (int32_t i = 0; i < ARG_COUNT; ++i) {
58 args = va_arg(va_args, char *);
59 }
60 va_end(va_args);
61 return HilogMock::GetMock()->HiLogPrint(type, level, domain, tag, fmt, args);
62 }
63 #endif // HILOG_RAWFORMAT
64