RDK Documentation (Open Sourced RDK Components)
btrMgr_logger.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 #ifndef __BTR_MGR_PRIV_H__
20 #define __BTR_MGR_PRIV_H__
21 
22 
23 #define PREFIX(format) "%d\t: %s - " format
24 
25 #ifdef RDK_LOGGER_ENABLED
26 
27 #include "rdk_debug.h"
28 
29 extern int b_rdk_logger_enabled;
30 
31 #define LOG_ERROR(format, ...) if(b_rdk_logger_enabled) {\
32  RDK_LOG(RDK_LOG_ERROR, "LOG.RDK.BTRMGR", format, __VA_ARGS__);\
33  } else {\
34  fprintf (stderr, format, __VA_ARGS__);\
35 }
36 #define LOG_WARN(format, ...) if(b_rdk_logger_enabled) {\
37  RDK_LOG(RDK_LOG_WARN, "LOG.RDK.BTRMGR", format, __VA_ARGS__);\
38  } else {\
39  fprintf (stderr, format, __VA_ARGS__);\
40 }
41 #define LOG_INFO(format, ...) if(b_rdk_logger_enabled) {\
42  RDK_LOG(RDK_LOG_INFO, "LOG.RDK.BTRMGR", format, __VA_ARGS__);\
43  } else {\
44  fprintf (stderr, format, __VA_ARGS__);\
45 }
46 #define LOG_DEBUG(format, ...) if(b_rdk_logger_enabled) {\
47  RDK_LOG(RDK_LOG_DEBUG, "LOG.RDK.BTRMGR", format, __VA_ARGS__);\
48  } else {\
49  fprintf (stderr, format, __VA_ARGS__);\
50 }
51 #define LOG_TRACE(format, ...) if(b_rdk_logger_enabled) {\
52  RDK_LOG(RDK_LOG_TRACE1, "LOG.RDK.BTRMGR", format, __VA_ARGS__);\
53  } else {\
54  fprintf (stderr, format, __VA_ARGS__);\
55 }
56 #else
57 
58 #include <stdio.h>
59 
60 #define LOG_ERROR(format, ...) fprintf(stderr, format, __VA_ARGS__)
61 #define LOG_WARN(format, ...) fprintf(stderr, format, __VA_ARGS__)
62 #define LOG_INFO(format, ...) fprintf(stderr, format, __VA_ARGS__)
63 #define LOG_DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
64 #define LOG_TRACE(format, ...) fprintf(stderr, format, __VA_ARGS__)
65 
66 #endif
67 
68 
69 #define BTRMGRLOG_ERROR(format, ...) LOG_ERROR(PREFIX(format), __LINE__, __FUNCTION__, ##__VA_ARGS__)
70 #define BTRMGRLOG_WARN(format, ...) LOG_WARN(PREFIX(format), __LINE__, __FUNCTION__, ##__VA_ARGS__)
71 #define BTRMGRLOG_INFO(format, ...) LOG_INFO(PREFIX(format), __LINE__, __FUNCTION__, ##__VA_ARGS__)
72 #define BTRMGRLOG_DEBUG(format, ...) LOG_DEBUG(PREFIX(format), __LINE__, __FUNCTION__, ##__VA_ARGS__)
73 #define BTRMGRLOG_TRACE(format, ...) LOG_TRACE(PREFIX(format), __LINE__, __FUNCTION__, ##__VA_ARGS__)
74 
75 
76 
77 #endif /* __BTR_MGR_PRIV_H__ */
rdk_debug.h