• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef __H_HDC_LOG_H__
16 #define __H_HDC_LOG_H__
17 
18 #include <cinttypes>
19 
20 namespace Hdc {
21 
22 namespace Base {
23     void PrintLogEx(const char *functionName, int line, uint8_t logLevel, const char *msg, ...);
24 }
25 
26 enum HdcLogLevel {
27     LOG_OFF,
28     LOG_FATAL,
29     LOG_WARN,
30     LOG_INFO,  // default
31     LOG_DEBUG,
32     LOG_ALL,
33     LOG_VERBOSE,
34     LOG_LAST = LOG_VERBOSE,  // tail, not use
35 };
36 
37 #ifdef IS_RELEASE_VERSION
38 #define WRITE_LOG(level, fmt, ...)   Base::PrintLogEx(__FUNCTION__, __LINE__, level, fmt, ##__VA_ARGS__)
39 #else
40 #define WRITE_LOG(level, fmt, ...)   Base::PrintLogEx(__FILE_NAME__, __LINE__, level, fmt, ##__VA_ARGS__)
41 #endif
42 
43 #ifndef HDC_HOST
44 #define WRITE_LOG_DAEMON(level, fmt, ...) WRITE_LOG(level, fmt, ##__VA_ARGS__)
45 #else
46 #define WRITE_LOG_DAEMON(level, fmt, ...)
47 #endif
48 
49 #ifdef HDC_DEBUG
50 #define DEBUG_LOG(fmt, ...)   WRITE_LOG(LOG_DEBUG, fmt, ##__VA_ARGS__)
51 #else
52 #define DEBUG_LOG(fmt, ...)
53 #endif
54 
55 }  // namespace Hdc
56 #endif  // __H_HDC_LOG_H__
57