RTI Connext DDS Micro
Version 2.4.10
Main Page
Related Pages
Manuals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
osapi_log_impl.h
Go to the documentation of this file.
1
/*
2
* FILE: osapi_log_impl.h - Implementation of Log functions
3
*
4
* Copyright 2008-2015 Real-Time Innovations, Inc.
5
*
6
* No duplications, whole or partial, manual or electronic, may be made
7
* without express written permission. Any such copies, or
8
* revisions thereof, must display this notice unaltered.
9
* This code contains trade secrets of Real-Time Innovations, Inc.
10
*
11
* Modification History
12
* --------------------
13
* 07mar2013,tk Updated
14
* 22sep2011,tk Updated
15
* 23sep2008,yy Created
16
*/
17
/*ce
18
* \file
19
* \brief Implementation of log functionality
20
*/
21
#include "
osapi/osapi_config.h
"
22
23
#ifndef osapi_log_impl_h
24
#define osapi_log_impl_h
25
26
#define OSAPI_TRACEKIND_NONE 0x00
27
#define OSAPI_TRACEKIND_NET 0x01
28
#define OSAPI_TRACEKIND_DDS 0x02
29
#define OSAPI_TRACEKIND_THREAD 0x04
30
31
#define NETIO_FORMAT(s_) "NETIO ...: " s_
32
#define DDSC_FORMAT(s_) "DDS .....: " s_
33
#define THREAD_FORMAT(s_) "THREAD ..: " s_
34
35
#if !OSAPI_ENABLE_TRACE
36
37
#define OSAPI_TRACE(title_,final_)
38
#define OSAPI_TRACE_DDS(title_,final_)
39
#define OSAPI_TRACE_NET(title_,final_)
40
#define OSAPI_TRACE_THREAD(title_,final_)
41
#define OSAPI_TRACE_INT32(name_,value_,final_)
42
#define OSAPI_TRACE_STRING(name_,value_,final_)
43
#define OSAPI_TRACE_GUID(name_,value_,final_)
44
#define OSAPI_TRACE_PTR(name_,value_,final_)
45
#define OSAPI_TRACE_A4_AS_INT32(name_,value_,final_)
46
#define OSAPI_TRACE_A12_AS_INT32(name_,value_,final_)
47
48
#define OSAPI_TRACE_ONLY_VARIABLE(x_) (void)(x_)
49
50
#else
51
52
#define OSAPI_TRACE_ONLY_VARIABLE(x_)
53
54
#define OSAPI_TRACE(title_,final_) \
55
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NONE),\
56
OSAPI_TRACETYPE_HEADER,title_,0,NULL,NULL,final_);
57
58
#define OSAPI_TRACE_KIND(c_) OSAPI_gv_TraceMask,OSAPI_gv_TraceFunctionParam,\
59
(c_),RTI_MODULE_NAME,__FILE__,__FUNCTION__,__LINE__
60
61
#define OSAPI_TRACE_DDS(title_,final_) \
62
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_DDS),\
63
OSAPI_TRACETYPE_HEADER,DDSC_FORMAT(title_),0,NULL,NULL,final_);
64
65
#define OSAPI_TRACE_NET(title_,final_) \
66
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NET),\
67
OSAPI_TRACETYPE_HEADER,NETIO_FORMAT(title_),0,NULL,NULL,final_);
68
69
#define OSAPI_TRACE_THREAD(title_,final_) \
70
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_THREAD),\
71
OSAPI_TRACETYPE_HEADER,THREAD_FORMAT(title_),0,NULL,NULL,final_);
72
73
#define OSAPI_TRACE_INT32(name_,value_,final_) \
74
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NONE),\
75
OSAPI_TRACETYPE_INT32,name_,value_,NULL,NULL,final_);
76
77
#define OSAPI_TRACE_STRING(name_,value_,final_) \
78
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NONE),\
79
OSAPI_TRACETYPE_STRING,name_,0,NULL,value_,final_);
80
81
#define OSAPI_TRACE_GUID(name_,value_,final_) \
82
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NONE),\
83
OSAPI_TRACETYPE_GUID,name_,0,value_,NULL,final_);
84
85
#define OSAPI_TRACE_PTR(name_,value_,final_) \
86
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NONE),\
87
OSAPI_TRACETYPE_PTR,name_,0,value_,NULL,final_);
88
89
#define OSAPI_TRACE_A4_AS_INT32(name_,value_,final_) \
90
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NONE),\
91
OSAPI_TRACETYPE_V4_AS_INT32 ,name_,0,value_,NULL,final_);
92
93
#define OSAPI_TRACE_A12_AS_INT32(name_,value_,final_) \
94
OSAPI_gv_TraceFunction(OSAPI_TRACE_KIND(OSAPI_TRACEKIND_NONE),\
95
OSAPI_TRACETYPE_V12_AS_INT32,name_,0,value_,NULL,final_);
96
97
#endif
98
99
#define OSAPI_PRECONDITION_PARAM OSAPI_LOGKIND_PRECONDITION,0,\
100
OSAPI_LOG_MSG_PN_X2_STD_PARAM
101
102
/*\ci
103
* \brief Add a pre-condition check independent of whether debug or release
104
* libraries are built.
105
*
106
* \sa OSAPI_LOG_PRECONDITION
107
*/
108
#if OSAPI_ENABLE_LOG
109
#define OSAPI_PRECONDITION_ALWAYS(cond_,action_,args_) \
110
if ((cond_)) \
111
{\
112
OSAPI_Log_entry_create(OSAPI_PRECONDITION_PARAM,RTI_FALSE);\
113
args_;\
114
action_;\
115
}
116
#else
117
#define OSAPI_PRECONDITION_ALWAYS(cond_,action_,args_) \
118
if ((cond_)) \
119
{\
120
action_;\
121
}
122
#endif
123
124
#if OSAPI_ENABLE_PRECONDITION
125
126
/*ci
127
* \brief Precondition test macro
128
*
129
* \details
130
*
131
* This macro is used to perform pre-condition checks, typically on
132
* function arguments. The macro automatically adds a log-entry and
133
* the user _must_ add at least one pre-condition argument, the one that
134
* filed, or more. The last argument added must have the is_final flag
135
* set to RTI_TRUE.
136
*
137
* Example:
138
*
139
* Consider the function:
140
*
141
* RTI_BOOL
142
* A_Function(void *pointer)
143
* {
144
* OSAPI_LOG_PRECONDITION(pointer != NULL, return RTI_FALSE,
145
* OSAPI_Log_entry_add_pointer("pointer",pointer,RTI_TRUE);)
146
*
147
* .....
148
* }
149
*
150
* This function tests whether the input pointer is NULL or not, and it its
151
* NULL adds the name and value of the pointer to the log-entry.
152
*
153
* RTI_BOOL
154
* Another_Function(void *pointer,RTI_INT32 length)
155
* {
156
* OSAPI_LOG_PRECONDITION(pointer != NULL || length > 100, return RTI_FALSE,
157
* OSAPI_Log_entry_add_pointer("pointer",pointer,RTI_FALSE);
158
* OSAPI_Log_entry_add_int("length",length,RTI_TRUE);)
159
*
160
* .....
161
* }
162
*
163
* This function tests whether the input pointer is NULL or not and that the
164
* length <= 100, otherwise both the arguments are added to the log-buffer.
165
* Note that the last entry as is_final set to RTI_TRUE to indicate to no
166
* more entries should be added to that current log-entries.
167
*
168
*
169
* \sa OSAPI_Log_entry_add_int
170
* \sa OSAPI_Log_entry_add_string
171
* \sa OSAPI_Log_entry_add_pointer
172
*
173
*/
174
#if OSAPI_ENABLE_LOG
175
#define OSAPI_PRECONDITION(cond_,action_,args_) \
176
if ((cond_)) \
177
{\
178
OSAPI_Log_entry_create(OSAPI_PRECONDITION_PARAM,RTI_FALSE);\
179
args_;\
180
action_;\
181
}
182
#else
183
#define OSAPI_PRECONDITION(cond_,action_,args_) \
184
if ((cond_)) \
185
{\
186
action_;\
187
}
188
#endif
189
190
#else
191
192
#define OSAPI_PRECONDITION(cond_,action_,args_)
193
194
#endif
195
196
#endif
/* osapi_log_impl_h */
RTI Connext DDS Micro Version 2.4.10
Copyright © Fri Jun 30 2017
Real-Time Innovations, Inc