RTI Connext DDS Micro  Version 2.4.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
osapi_log.h
1 /*
2  * FILE: osapi_log.h - Logging API
3  *
4  * (c) Copyright, Real-Time Innovations, 2008-2015.
5  *
6  * All rights reserved.
7  *
8  * No duplications, whole or partial, manual or electronic, may be made
9  * without express written permission. Any such copies, or
10  * revisions thereof, must display this notice unaltered.
11  * This code contains trade secrets of Real-Time Innovations, Inc.
12  *
13  * modification history
14  * --------------------
15  * 04nov2015,tk MICRO-1505 Reduce memory footprint
16  * 02dec2014,tk MICRO-9763/PR#12922 Added documentation for log-entry use
17  * 16sep2014,tk MICRO-887/PR#10752 Removed reference to removed function
18  * 22sep2011,tk Updated
19  * 23sep2008,yy Created
20  *
21  */
22 /*ci
23  * \file
24  * \brief OSAPI Log API
25  * \addtogroup OSAPILogClass OSAPI Logging
26  */
27 #ifndef osapi_log_h
28 #define osapi_log_h
29 
30 #ifndef osapi_dll_h
31 #include "osapi/osapi_dll.h"
32 #endif /* */
33 #ifndef osapi_thread_h
34 #include "osapi/osapi_thread.h"
35 #endif /* */
36 #ifndef osapi_heap_h
37 #include "osapi/osapi_heap.h"
38 #endif /* */
39 #ifndef osapi_system_h
40 #include "osapi/osapi_system.h"
41 #endif /* */
42 
43 #ifdef __cplusplus
44 extern "C"
45 {
46 #endif
47 
48 /******************************************************************************
49  * OSAPI Error codes
50  ******************************************************************************/
51 
52 #ifndef RTI_MODULE_NAME
53 #define RTI_MODULE_NAME "undefined"
54 #endif
55 
56 #define OSAPI_LOG_MSG_PN_X2_STD_PARAM RTI_MODULE_NAME,\
57  __FILE__,__FUNCTION__, __LINE__
58 
59 #if OSAPI_ENABLE_LOG
60 #define OSAPI_LOG_ENTRY_CREATE(kind_,error_code_,p_,is_finale_)\
61  OSAPI_Log_entry_create(kind_,error_code_,p_,is_finale_);
62 
63 #define OSAPI_LOG_ENTRY_ADD(kind_,error_code_,p_)\
64  OSAPI_Log_entry_add(kind_,error_code_,p_);
65 
66 #define OSAPI_LOG_ENTRY_ADD_INT(name_,value_,is_final_)\
67  OSAPI_Log_entry_add_int(name_,value_,is_final_);
68 
69 #define OSAPI_LOG_ENTRY_ADD_STRING(name_,value_,is_final_)\
70  OSAPI_Log_entry_add_string(name_,value_,is_final_);
71 
72 #define OSAPI_LOG_ENTRY_ADD_POINTER(name_,value_,is_final_)\
73  OSAPI_Log_entry_add_pointer(name_,value_,is_final_);\
74 
75 #define OSAPI_LOG_ENTRY_ADD_1STRING_1INT(kind_,error_code_,p_,s_name_,s_value_,i_name_,i_value_)\
76  OSAPI_Log_entry_add_1string_1int(kind_,error_code_,p_,s_name_,s_value_,i_name_,i_value_);
77 
78 #define OSAPI_LOG_ENTRY_ADD_1POINTER(kind_,error_code_,p_,name_,value_)\
79  OSAPI_Log_entry_add_1pointer(kind_,error_code_,p_,name_,value_);
80 
81 #define OSAPI_LOG_ENTRY_ADD_1STRING(kind_,error_code_,p_,name_,value_)\
82  OSAPI_Log_entry_add_1string(kind_,error_code_,p_,name_,value_);
83 
84 #define OSAPI_LOG_ENTRY_ADD_2STRING(kind_,error_code_,p_,name1_,value1_,name2_,value2_)\
85  OSAPI_Log_entry_add_2string(kind_,error_code_,p_,name1_,value1_,name2_,value2_);
86 
87 #define OSAPI_LOG_ENTRY_ADD_1INT(kind_,error_code_,p_,name1_,value1_)\
88  OSAPI_Log_entry_add_1int(kind_,error_code_,p_,name1_,value1_);
89 
90 #define OSAPI_LOG_ENTRY_ADD_2INT(kind_,error_code_,p_,name1_,value1_,name2_,value2_)\
91  OSAPI_Log_entry_add_2int(kind_,error_code_,p_,name1_,value1_,name2_,value2_);
92 
93 #define OSAPI_LOG_ENTRY_ADD_3INT(kind_,error_code_,p_,name1_,value1_,name2_,value2_,name3_,value3_)\
94  OSAPI_Log_entry_add_3int(kind_,error_code_,p_,name1_,value1_,name2_,value2_,name3_,value3_);
95 #else
96 #define OSAPI_LOG_ENTRY_CREATE(kind_,error_code_,p_,is_finale_)
97 #define OSAPI_LOG_ENTRY_ADD_INT(name_,value_,is_final_)
98 #define OSAPI_LOG_ENTRY_ADD_STRING(name_,value_,is_final_)
99 #define OSAPI_LOG_ENTRY_ADD_POINTER(name_,value_,is_final_)
100 #define OSAPI_LOG_ENTRY_ADD_1STRING_1INT(kind_,error_code_,p_,s_name_,s_value_,i_name_,i_value_)
101 #define OSAPI_LOG_ENTRY_ADD_1POINTER(kind_,error_code_,p_,name_,value_)
102 #define OSAPI_LOG_ENTRY_ADD_1STRING(kind_,error_code_,p_,name_,value_)
103 #define OSAPI_LOG_ENTRY_ADD_2STRING(kind_,error_code_,p_,name1_,value1_,name2_,value2_)
104 #define OSAPI_LOG_ENTRY_ADD_1INT(kind_,error_code_,p_,name1_,value1_)
105 #define OSAPI_LOG_ENTRY_ADD_2INT(kind_,error_code_,p_,name1_,value1_,name2_,value2_)
106 #define OSAPI_LOG_ENTRY_ADD_3INT(kind_,error_code_,p_,name1_,value1_,name2_,value2_,name3_,value3_)
107 #define OSAPI_LOG_ENTRY_ADD(kind_,error_code_,p_)
108 #endif
109 
110 /*ce
111  * \defgroup OSAPILogCodesClass OSAPI
112  * \ingroup LoggingModule
113  *
114  * \details
115  * The logging API provides a number of functions for logging different
116  * types of events. There are 3 types of events:
117  *
118  * info - This type is for informational purposes
119  *
120  * warning - This type does not necessarily cause any functional behavior,
121  * but could indicate an unexpected situation has been handled
122  * or performance could be affected.
123  *
124  * error - This indicated an error condition that has functional impact
125  * and could not be dealt with.
126  *
127  * \brief OS API. ModuleID = 0
128  */
129 
130 /******************************************************************************
131  * OSAPI Log Modules
132  ******************************************************************************/
133 /*ce \def OSAPI_LOG_BASE
134  * \brief Log Id base-number
135  */
136 #define OSAPI_LOG_BASE (0)
137 
138 /*ce \def REDA_LOG_BASE
139  * \brief REDA Module
140  */
141 #define REDA_LOG_BASE (1 << 16)
142 
143 /*ce \def DB_LOG_BASE
144  * \brief DB Module
145  */
146 #define DB_LOG_BASE (2 << 16)
147 
148 /*ce \def RT_LOG_BASE
149  * \brief RT Module
150  */
151 #define RT_LOG_BASE (3 << 16)
152 
153 /*ce \def NETIO_LOG_BASE
154  * \brief NETIO Module
155  */
156 #define NETIO_LOG_BASE (4 << 16)
157 
158 /*ce \def UDP_LOG_BASE
159  * \brief UDP Module, same as NETIO
160  */
161 #define UDP_LOG_BASE NETIO_LOG_BASE
162 
163 /*ce \def CDR_LOG_BASE
164  * \brief CDR Module
165  */
166 #define CDR_LOG_BASE (5 << 16)
167 
168 /*ce \def RTPS_LOG_BASE
169  * \brief RTPS Module
170  */
171 #define RTPS_LOG_BASE (6 << 16)
172 
173 /*ce \def DDSC_LOG_BASE
174  * \brief DDS_C Module
175  */
176 #define DDSC_LOG_BASE (7 << 16)
177 
178 /*ce \def RHSM_LOG_BASE
179  * \brief RHSM Module
180  */
181 #define RHSM_LOG_BASE (8 << 16)
182 
183 /*ce \def WHSM_LOG_BASE
184  * \brief WHSM Module
185  */
186 #define WHSM_LOG_BASE (9 << 16)
187 
188 /*ce \def DPSE_LOG_BASE
189  * \brief DPSE Module
190  */
191 #define DPSE_LOG_BASE (10 << 16)
192 
193 /*ce \def DPDE_LOG_BASE
194  * \brief DPDE Module
195  */
196 #define DPDE_LOG_BASE (11 << 16)
197 
198 /*ce
199  * \brief Retrieving the next error code failed
200  * \ingroup OSAPILogCodesClass
201  */
202 #define OSAPI_LOG_GET_NEXT_OBJECT_ID_EC (OSAPI_LOG_BASE + 1)
203 #define OSAPI_LOG_GET_NEXT_OBJECT_ID(level_) \
204 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_GET_NEXT_OBJECT_ID_EC ,\
205  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
206 
207 /* System messages */
208 
209 /*ce
210  * \brief An error occured while setting the system properties
211  * \ingroup OSAPILogCodesClass
212  */
213 #define OSAPI_LOG_SYSTEM_SET_PROPERTY_EC (OSAPI_LOG_BASE + 2)
214 #define OSAPI_LOG_SYSTEM_SET_PROPERTY(level_) \
215 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_SYSTEM_SET_PROPERTY_EC,\
216  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
217 
218 /*ce
219  * \brief An error occured when starting the system timer
220  * \ingroup OSAPILogCodesClass
221  */
222 #define OSAPI_LOG_SYSTEM_TIMER_START_EC (OSAPI_LOG_BASE + 4)
223 #define OSAPI_LOG_SYSTEM_TIMER_START(level_) \
224 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_SYSTEM_TIMER_START_EC,\
225  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
226 
227 /*ce
228  * \brief An error occured when stopping the system timer
229  * \ingroup OSAPILogCodesClass
230  */
231 #define OSAPI_LOG_SYSTEM_TIMER_STOP_EC (OSAPI_LOG_BASE + 5)
232 #define OSAPI_LOG_SYSTEM_TIMER_STOP(level_) \
233 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_SYSTEM_TIMER_STOP_EC,\
234  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
235 
236 /* THREAD message */
237 /*ce
238  * \brief An error when allocating the a thread object
239  * \ingroup OSAPILogCodesClass
240  */
241 #define OSAPI_LOG_THREAD_NEW_EC (OSAPI_LOG_BASE + 6)
242 #define OSAPI_LOG_THREAD_NEW(level_) \
243 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_THREAD_NEW_EC,\
244  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
245 
246 /*ce
247  * \brief An error when creating the a thread object
248  * \ingroup OSAPILogCodesClass
249  */
250 #define OSAPI_LOG_THREAD_CREATE_EC (OSAPI_LOG_BASE + 7)
251 #define OSAPI_LOG_THREAD_CREATE(level_) \
252 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_THREAD_CREATE_EC,\
253  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
254 
255 /*ce
256  * \brief An error when creating thread sync semaphore
257  * \ingroup OSAPILogCodesClass
258  */
259 #define OSAPI_LOG_THREAD_SEM_EC (OSAPI_LOG_BASE + 8)
260 #define OSAPI_LOG_THREAD_SEM(level_,cs_,ss_) \
261 OSAPI_LOG_ENTRY_CREATE((level_),OSAPI_LOG_THREAD_SEM_EC,\
262  OSAPI_LOG_MSG_PN_X2_STD_PARAM,RTI_FALSE)\
263  OSAPI_LOG_ENTRY_ADD_POINTER("cs",(cs_),RTI_FALSE)\
264  OSAPI_LOG_ENTRY_ADD_POINTER("ss",(ss_),RTI_TRUE)
265 
266 /*ce
267  * \brief Failed to signal that a thread has been created
268  * \ingroup OSAPILogCodesClass
269  */
270 #define OSAPI_LOG_THREAD_EXEC_CREATE_EC (OSAPI_LOG_BASE + 9)
271 #define OSAPI_LOG_THREAD_EXEC_CREATE(level_) \
272 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_THREAD_EXEC_CREATE_EC,\
273  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
274 
275 /*ce
276  * \brief Failed to signal the start a created thread
277  * \ingroup OSAPILogCodesClass
278  */
279 #define OSAPI_LOG_THREAD_EXEC_START_EC (OSAPI_LOG_BASE + 10)
280 #define OSAPI_LOG_THREAD_EXEC_START(level_,ss_) \
281 OSAPI_LOG_ENTRY_ADD_1POINTER((level_),OSAPI_LOG_THREAD_EXEC_START_EC,\
282  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"ss",(ss_))
283 
284 /*ce
285  * \brief Failed to start a thread
286  * \ingroup OSAPILogCodesClass
287  */
288 #define OSAPI_LOG_THREAD_START_EC (OSAPI_LOG_BASE + 11)
289 #define OSAPI_LOG_THREAD_START(level_,ss_) \
290 OSAPI_LOG_ENTRY_ADD_1POINTER((level_),OSAPI_LOG_THREAD_START_EC,\
291  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"ss",(ss_))
292 
293 /*ce
294  * \brief Failed to destroy a thread
295  * \ingroup OSAPILogCodesClass
296  */
297 #define OSAPI_LOG_THREAD_DESTROY_EC (OSAPI_LOG_BASE + 12)
298 #define OSAPI_LOG_THREAD_DESTROY(level_,ss_) \
299 OSAPI_LOG_ENTRY_ADD_1POINTER((level_),OSAPI_LOG_THREAD_DESTROY_EC,\
300  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"ss",(ss_))
301 
302 /*ce
303  * \brief Failed to start an unstarted thread being destroyed
304  * \ingroup OSAPILogCodesClass
305  */
306 #define OSAPI_LOG_THREAD_DESTROY_NO_START_EC (OSAPI_LOG_BASE + 13)
307 #define OSAPI_LOG_THREAD_DESTROY_NO_START(level_,ss_) \
308 OSAPI_LOG_ENTRY_ADD_1POINTER((level_),OSAPI_LOG_THREAD_DESTROY_NO_START_EC,\
309  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"ss",(ss_))
310 
311 /*ce
312  * \brief Failed wakeup of a thread being destroyed
313  * \ingroup OSAPILogCodesClass
314  */
315 #define OSAPI_LOG_THREAD_DESTROY_NO_WAKEUP_EC (OSAPI_LOG_BASE + 14)
316 #define OSAPI_LOG_THREAD_DESTROY_NO_WAKEUP(level_,ss_) \
317 OSAPI_LOG_ENTRY_ADD_1POINTER((level_),OSAPI_LOG_THREAD_DESTROY_NO_WAKEUP_EC,\
318  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"ss",(ss_))
319 
320 /*ce
321  * \brief Failed initializing a thread
322  * \ingroup OSAPILogCodesClass
323  */
324 #define OSAPI_LOG_THREAD_INIT_EC (OSAPI_LOG_BASE + 15)
325 #define OSAPI_LOG_THREAD_INIT(level_,sysrc_) \
326 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_THREAD_INIT_EC,\
327  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
328 
329 
330 /*ce
331  * \brief Failed to set scheduling policy of a thread
332  * \ingroup OSAPILogCodesClass
333  */
334 #define OSAPI_LOG_THREAD_SCHEDPARAM_EC (OSAPI_LOG_BASE + 16)
335 #define OSAPI_LOG_THREAD_SCHEDPARAM(level_,sysrc_,prio_) \
336 OSAPI_LOG_ENTRY_ADD_2INT((level_),OSAPI_LOG_THREAD_SCHEDPARAM_EC ,\
337  OSAPI_LOG_MSG_PN_X2_STD_PARAM,\
338  "sysrc",(sysrc_),"prio",(prio_))
339 
340 /*ce
341  * \brief Failed to get the scheduling policy of a thread
342  * \ingroup OSAPILogCodesClass
343  */
344 #define OSAPI_LOG_THREAD_GET_POLICY_EC (OSAPI_LOG_BASE + 17)
345 #define OSAPI_LOG_THREAD_GET_POLICY(level_,sysrc_) \
346 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_THREAD_GET_POLICY_EC,\
347  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
348 
349 /*ce
350  * \brief Mismatch of scheduling policy of a created thread and the application
351  * thread
352  * \ingroup OSAPILogCodesClass
353  */
354 #define OSAPI_LOG_THREAD_POLICY_DIFFER_EC (OSAPI_LOG_BASE + 18)
355 #define OSAPI_LOG_THREAD_POLICY_DIFFER(level_,get_policy_,set_policy_) \
356 OSAPI_LOG_ENTRY_ADD_2INT((level_),OSAPI_LOG_THREAD_POLICY_DIFFER_EC,\
357  OSAPI_LOG_MSG_PN_X2_STD_PARAM,\
358  "get_policy",(get_policy_),"set_policy",(set_policy_))
359 
360 /*ce
361  * \brief Failed to map to native thread priority values
362  * \ingroup OSAPILogCodesClass
363  */
364 #define OSAPI_LOG_THREAD_PRIORITY_MAP_EC (OSAPI_LOG_BASE + 19)
365 #define OSAPI_LOG_THREAD_PRIORITY_MAP(level_,min_,max_) \
366 OSAPI_LOG_ENTRY_ADD_2INT((level_),OSAPI_LOG_THREAD_PRIORITY_MAP_EC,\
367  OSAPI_LOG_MSG_PN_X2_STD_PARAM,\
368  "min",(min_),"max",(max_))
369 
370 /* TIMER messages */
371 
372 /*ce
373  * \brief Failed to delete the Timer object
374  * \ingroup OSAPILogCodesClass
375  */
376 #define OSAPI_LOG_TIMER_DELETE_EC (OSAPI_LOG_BASE + 20)
377 #define OSAPI_LOG_TIMER_DELETE(level_) \
378 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_TIMER_DELETE_EC,\
379  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
380 
381 #define OSAPI_LOG_TIMER_TICK_EC (OSAPI_LOG_BASE + 21)
382 
383 /*ce
384  * \brief Failed taking or giving the Timer mutex
385  * \ingroup OSAPILogCodesClass
386  */
387 #define OSAPI_LOG_TIMER_TICK_MUTEX_EC (OSAPI_LOG_BASE + 22)
388 #define OSAPI_LOG_TIMER_TICK_MUTEX(level_,mutex_,take_) \
389 OSAPI_LOG_ENTRY_CREATE((level_),OSAPI_LOG_TIMER_TICK_MUTEX_EC,\
390  OSAPI_LOG_MSG_PN_X2_STD_PARAM,RTI_FALSE)\
391 OSAPI_LOG_ENTRY_ADD_POINTER("mutex",(mutex_),RTI_FALSE)\
392 OSAPI_LOG_ENTRY_ADD_INT("take",(take_),RTI_TRUE)
393 
394 #define OSAPI_LOG_TIMER_CREATE_TIMEOUT_EC (OSAPI_LOG_BASE + 23)
395 
396 #define OSAPI_LOG_TIMER_UPDATE_TIMEOUT_EC (OSAPI_LOG_BASE + 24)
397 
398 #define OSAPI_LOG_TIMER_DELETE_TIMEOUT_EC (OSAPI_LOG_BASE + 25)
399 
400 
401 /*ce
402  * \brief Failed to return user data for a timeout due to mismatched epochs
403  * \ingroup OSAPILogCodesClass
404  */
405 #define OSAPI_LOG_TIMER_GET_USER_DATA_EPOCH_EC (OSAPI_LOG_BASE + 27)
406 #define OSAPI_LOG_TIMER_GET_USER_DATA_EPOCH(level_,h_,e_,e1_,e2_) \
407 OSAPI_LOG_ENTRY_CREATE( (level_),OSAPI_LOG_TIMER_GET_USER_DATA_EPOCH_EC,\
408  OSAPI_LOG_MSG_PN_X2_STD_PARAM,RTI_FALSE)\
409  OSAPI_LOG_ENTRY_ADD_POINTER("h",(h_),RTI_FALSE)\
410  OSAPI_LOG_ENTRY_ADD_POINTER("e",(e_),RTI_FALSE)\
411  OSAPI_LOG_ENTRY_ADD_INT("e1",(e1_),RTI_FALSE)\
412  OSAPI_LOG_ENTRY_ADD_INT("e2",(e2_),RTI_TRUE)
413 /*ce
414  * \brief Failed to allocate memory for a new Timer
415  * \ingroup OSAPILogCodesClass
416  */
417 #define OSAPI_LOG_TIMER_NEW_EC (OSAPI_LOG_BASE + 28)
418 #define OSAPI_LOG_TIMER_NEW(level_) \
419 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_TIMER_NEW_EC,\
420  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
421 
422 /*ce
423  * \brief Failed to allocate memory for a new Timer entry
424  * \ingroup OSAPILogCodesClass
425  */
426 #define OSAPI_LOG_TIMER_NEW_ENTRY_EC (OSAPI_LOG_BASE + 29)
427 #define OSAPI_LOG_TIMER_NEW_ENTRY(level_) \
428 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_TIMER_NEW_ENTRY_EC,\
429  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
430 
431 /*ce
432  * \brief Failed to allocate memory for a new Timer wheel
433  * \ingroup OSAPILogCodesClass
434  */
435 #define OSAPI_LOG_TIMER_NEW_WHEEL_EC (OSAPI_LOG_BASE + 30)
436 #define OSAPI_LOG_TIMER_NEW_WHEEL(level_,slots_) \
437 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_TIMER_NEW_WHEEL_EC,\
438  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"slots",(slots_))
439 
440 /*ce
441  * \brief Failed to create a new Timer mutex
442  * \ingroup OSAPILogCodesClass
443  */
444 #define OSAPI_LOG_TIMER_NEW_MUTEX_EC (OSAPI_LOG_BASE + 31)
445 #define OSAPI_LOG_TIMER_NEW_MUTEX(level_) \
446 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_TIMER_NEW_MUTEX_EC,\
447  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
448 
449 /*ce
450  * \brief Failed to start a new Timer being created
451  * \ingroup OSAPILogCodesClass
452  */
453 #define OSAPI_LOG_TIMER_NEW_START_TIMER_EC (OSAPI_LOG_BASE + 32)
454 #define OSAPI_LOG_TIMER_NEW_START_TIMER(level_,timer_,ticr_) \
455 OSAPI_LOG_ENTRY_CREATE((level_),OSAPI_LOG_TIMER_NEW_START_TIMER_EC,\
456  OSAPI_LOG_MSG_PN_X2_STD_PARAM,RTI_FALSE)\
457  OSAPI_LOG_ENTRY_ADD_POINTER("timer",(timer_),RTI_FALSE)\
458  OSAPI_LOG_ENTRY_ADD_POINTER("ticr",(ticr_),RTI_TRUE)
459 
460 /*ce
461  * \brief Failed to stop a Timer being deleted
462  * \ingroup OSAPILogCodesClass
463  */
464 #define OSAPI_LOG_TIMER_DELETE_STOP_TIMER_EC (OSAPI_LOG_BASE + 33)
465 #define OSAPI_LOG_TIMER_DELETE_STOP_TIMER(level_,timer_) \
466 OSAPI_LOG_ENTRY_ADD_1POINTER((level_),OSAPI_LOG_TIMER_DELETE_STOP_TIMER_EC,\
467  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"timer",(timer_))
468 
469 /*ce
470  * \brief Failed to delete the Timer mutex
471  * \ingroup OSAPILogCodesClass
472  */
473 #define OSAPI_LOG_TIMER_DELETE_MUTEX_EC (OSAPI_LOG_BASE + 34)
474 #define OSAPI_LOG_TIMER_DELETE_MUTEX(level_,timer_) \
475 OSAPI_LOG_ENTRY_ADD_1POINTER((level_),OSAPI_LOG_TIMER_DELETE_MUTEX_EC,\
476  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"timer",(timer_))
477 
478 /*ce
479  * \brief Failed to take or give a Timer mutex
480  * \ingroup OSAPILogCodesClass
481  */
482 #define OSAPI_LOG_TIMER_MUTEX_EC (OSAPI_LOG_BASE + 35)
483 #define OSAPI_LOG_TIMER_MUTEX(level_,mutex_,take_) \
484  OSAPI_LOG_ENTRY_CREATE((level_),OSAPI_LOG_TIMER_MUTEX_EC,OSAPI_LOG_MSG_PN_X2_STD_PARAM,RTI_FALSE)\
485  OSAPI_LOG_ENTRY_ADD_POINTER("mutex",(mutex_),RTI_FALSE)\
486  OSAPI_LOG_ENTRY_ADD_INT("take",(take_),RTI_TRUE)
487 
488 /* Semaphore messages */
489 
490 /*ce
491  * \brief Failed to delete a semaphore
492  * \ingroup OSAPILogCodesClass
493  */
494 #define OSAPI_LOG_SEMAPHORE_DELETE_EC (OSAPI_LOG_BASE + 36)
495 #define OSAPI_LOG_SEMAPHORE_DELETE(level_,sysrc_) \
496 OSAPI_LOG_ENTRY_ADD_1INT( (level_),OSAPI_LOG_SEMAPHORE_DELETE_EC,\
497  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
498 
499 /*ce
500  * \brief Failed to create a semaphore
501  * \ingroup OSAPILogCodesClass
502  */
503 #define OSAPI_LOG_SEMAPHORE_NEW_EC (OSAPI_LOG_BASE + 37)
504 #define OSAPI_LOG_SEMAPHORE_NEW(level_) \
505 OSAPI_LOG_ENTRY_ADD( (level_),OSAPI_LOG_SEMAPHORE_NEW_EC,\
506  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
507 
508 /*ce
509  * \brief Failed to initialize a new semaphore
510  * \ingroup OSAPILogCodesClass
511  */
512 #define OSAPI_LOG_SEMAPHORE_NEW_INIT_EC (OSAPI_LOG_BASE + 38)
513 #define OSAPI_LOG_SEMAPHORE_NEW_INIT(level_,sysrc_) \
514 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_SEMAPHORE_NEW_INIT_EC,\
515  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
516 
517 /*ce
518  * \brief Failed to give a semaphore
519  * \ingroup OSAPILogCodesClass
520  */
521 #define OSAPI_LOG_SEMAPHORE_GIVE_EC (OSAPI_LOG_BASE + 39)
522 #define OSAPI_LOG_SEMAPHORE_GIVE(level_,sysrc_) \
523 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_SEMAPHORE_GIVE_EC,\
524  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
525 
526 /*ce
527  * \brief Failed to take a semaphore
528  * \ingroup OSAPILogCodesClass
529  */
530 #define OSAPI_LOG_SEMAPHORE_TAKE_EC (OSAPI_LOG_BASE + 40)
531 #define OSAPI_LOG_SEMAPHORE_TAKE(level_,sysrc_) \
532 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_SEMAPHORE_TAKE_EC,\
533  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
534 
535 /* Mutex messages */
536 
537 /*ce
538  * \brief Failed to delete a mutex
539  * \ingroup OSAPILogCodesClass
540  */
541 #define OSAPI_LOG_MUTEX_DELETE_EC (OSAPI_LOG_BASE + 41)
542 #define OSAPI_LOG_MUTEX_DELETE(level_,sysrc_) \
543 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_MUTEX_DELETE_EC,\
544  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
545 
546 /*ce
547  * \brief Failed to create a mutex
548  * \ingroup OSAPILogCodesClass
549  */
550 #define OSAPI_LOG_MUTEX_NEW_EC (OSAPI_LOG_BASE + 42)
551 #define OSAPI_LOG_MUTEX_NEW(level_) \
552 OSAPI_LOG_ENTRY_ADD((level_),OSAPI_LOG_MUTEX_NEW_EC,\
553  OSAPI_LOG_MSG_PN_X2_STD_PARAM)
554 
555 /*ce
556  * \brief Failed to take a mutex
557  * \ingroup OSAPILogCodesClass
558  */
559 #define OSAPI_LOG_MUTEX_TAKE_EC (OSAPI_LOG_BASE + 43)
560 #define OSAPI_LOG_MUTEX_TAKE(level_,sysrc_) \
561 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_MUTEX_TAKE_EC,\
562  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
563 
564 /*ce
565  * \brief Failed to give a mutex
566  * \ingroup OSAPILogCodesClass
567  */
568 #define OSAPI_LOG_MUTEX_GIVE_EC (OSAPI_LOG_BASE + 44)
569 #define OSAPI_LOG_MUTEX_GIVE(level_,sysrc_) \
570 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_MUTEX_GIVE_EC,\
571  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
572 
573 /*ce
574  * \brief Failed to initialize a mutex
575  * \ingroup OSAPILogCodesClass
576  */
577 #define OSAPI_LOG_MUTEX_INIT_EC (OSAPI_LOG_BASE + 45)
578 #define OSAPI_LOG_MUTEX_INIT(level_,sysrc_) \
579 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_MUTEX_INIT_EC,\
580  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
581 
582 /* HEAP */
583 
584 /*ce
585  * \brief Failed to allocate a buffer from the heap
586  * \ingroup OSAPILogCodesClass
587  */
588 #define OSAPI_LOG_HEAP_INTERNAL_ALLOCATE_EC (OSAPI_LOG_BASE + 46)
589 #define OSAPI_LOG_HEAP_INTERNAL_ALLOCATE(level_,s_,a_) \
590 OSAPI_LOG_ENTRY_ADD_2INT((level_),OSAPI_LOG_HEAP_INTERNAL_ALLOCATE_EC,\
591  OSAPI_LOG_MSG_PN_X2_STD_PARAM,\
592  "s",(s_),"a",(a_))
593 
594 #define OSAPI_LOG_HEAP_FREE_EC (OSAPI_LOG_BASE + 47)
595 
596 /*ce
597  * \brief Failed to get current system time
598  * \ingroup OSAPILogCodesClass
599  */
600 #define OSAPI_LOG_SYSTEM_GET_TIME_EC (OSAPI_LOG_BASE + 48)
601 #define OSAPI_LOG_SYSTEM_GET_TIME(level_,sysrc_) \
602 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_SYSTEM_GET_TIME_EC,\
603  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"sysrc",(sysrc_))
604 
605 /*ce
606  * \brief Return the last recorded error-code for the calling thread
607  *
608  * \details
609  * This log-messages retrieves the last recorded error-code for the
610  * calling thread. It is used a function calls another function that
611  * fails.
612  *
613  * \ingroup OSAPILogCodesClass
614  */
615 #define OSAPI_LOG_LAST_RECORDED_ERROR_EC (OSAPI_LOG_BASE + 49)
616 #define OSAPI_LOG_LAST_RECORDED_ERROR(level_) \
617 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_LAST_RECORDED_ERROR_EC,\
618  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"rc",OSAPI_Log_get_last_error_code())
619 
620 /*ce
621  * \brief Failed to set the thread name in the OS
622  *
623  * \details
624  * When OSAPI starts a thread it also calls the OS to set the thread name. If this
625  * fails this warning message indicates why.
626  *
627  * \ingroup OSAPILogCodesClass
628  */
629 #define OSAPI_LOG_SET_THREAD_NAME_EC (OSAPI_LOG_BASE + 50)
630 #define OSAPI_LOG_SET_THREAD_NAME(level_,rc_) \
631 OSAPI_LOG_ENTRY_ADD_1INT((level_),OSAPI_LOG_SET_THREAD_NAME_EC,\
632  OSAPI_LOG_MSG_PN_X2_STD_PARAM,"rc",(rc_))
633 
634 /******************************************************************************/
635 
636 #if OSAPI_ENABLE_LOG
637 /******************************************************************************
638  * Log types
639  ******************************************************************************/
640 /*ci
641  * \ingroup OSAPILogClass
642  * \brief Log message as an error
643  */
644 typedef enum
645 {
646  OSAPI_LOGKIND_ERROR = 0,
647  OSAPI_LOGKIND_WARNING,
648  OSAPI_LOGKIND_INFO,
649  OSAPI_LOGKIND_PRECONDITION
650 } OSAPI_LogKind_T;
651 
652 typedef RTI_UINT32 OSAPI_LogEntryHeader_T;
653 typedef RTI_UINT32 OSAPI_LogEntryPayloadElement_T;
654 
655 /* 31 30 29 28-27 26-16 15 14-0
656  * +---+---+---+------+--------+--------+
657  * | X | E | T | TYPE | MODULE | F | EC |
658  * +---+---+---+------+--------+--------+
659  */
660 #define OSAPI_LOG_HEADER_GET_X(hdr_) ((hdr_)>>31)
661 #define OSAPI_LOG_HEADER_GET_E(hdr_) ((hdr_)>>30 & 0x1)
662 #define OSAPI_LOG_HEADER_GET_T(hdr_) ((hdr_)>>29 & 0x1)
663 #define OSAPI_LOG_HEADER_GET_TYPE(hdr_) (((hdr_) >>27) & 0x3)
664 #define OSAPI_LOG_HEADER_GET_MODULE(hdr_) (((hdr_) >>16) & 0x7ff)
665 #define OSAPI_LOG_HEADER_GET_EC(hdr_) ((hdr_) & 0x7fff)
666 #define OSAPI_LOG_HEADER_GET_F(hdr_) ((hdr_)>>15 & 0x1)
667 
668 #define OSAPI_LOG_HEADER_SET_X(hdr_) ((hdr_) |= 0x80000000)
669 #define OSAPI_LOG_HEADER_CLR_X(hdr_) ((hdr_) &= ~0x80000000)
670 #define OSAPI_LOG_HEADER_SET_E(hdr_) ((hdr_) |= 0x40000000)
671 #define OSAPI_LOG_HEADER_SET_T(hdr_) ((hdr_) |= 0x20000000)
672 #define OSAPI_LOG_HEADER_CLR_T(hdr_) ((hdr_) &= ~0x20000000)
673 #define OSAPI_LOG_HEADER_SET_TYPE(hdr_,type_) ((hdr_) |= ((type_) << 27))
674 #define OSAPI_LOG_HEADER_SET_MODULE(hdr_,m_) ((hdr_) |= ((m_) << 16))
675 #define OSAPI_LOG_HEADER_SET_EC(hdr_,ec) ((hdr_) |= (ec_))
676 #define OSAPI_LOG_HEADER_SET_F(hdr_) ((hdr_) |= 0x8000)
677 #define OSAPI_LOG_HEADER_CLR_F(hdr_) ((hdr_) &= ~0x8000)
678 
679 #define OSAPI_LOG_STATUS_MN (0x80000000)
680 #define OSAPI_LOG_STATUS_SF (0x40000000)
681 #define OSAPI_LOG_STATUS_FN (0x20000000)
682 #define OSAPI_LOG_STATUS_LN (0x10000000)
683 #define OSAPI_LOG_STATUS_F (0x08000000)
684 
685 #define OSAPI_LOG_STATUS_ALL \
686  (OSAPI_LOG_STATUS_MN | \
687  OSAPI_LOG_STATUS_SF | \
688  OSAPI_LOG_STATUS_FN | \
689  OSAPI_LOG_STATUS_LN)
690 
691 #define OSAPI_LOG_STATUS_NO_DATA \
692  (OSAPI_LOG_STATUS_MN | \
693  OSAPI_LOG_STATUS_SF | \
694  OSAPI_LOG_STATUS_FN | \
695  OSAPI_LOG_STATUS_LN)
696 
697 typedef enum
698 {
699  OSAPI_LOGTYPE_INTEGER,
700  OSAPI_LOGTYPE_STRING,
701  OSAPI_LOGTYPE_POINTER
702 } OSAPI_LogType_T;
703 
704 typedef struct OSAPI_LogDataEntry
705 {
706  OSAPI_LogType_T type;
707  char *name;
708  union
709  {
710  RTI_INT32 int_value;
711  char *string_value;
712  void *ptr_value;
713  } value;
714 } OSAPI_LogDataEntry_T;
715 
716 #define OSAPI_LOGDATA_SET_F(hdr_) ((hdr_) |= 0x80000000)
717 #define OSAPI_LOGDATA_GET_F(hdr_) ((hdr_)>>31 & 0x1)
718 #define OSAPI_LOGDATA_SET_TYPE(hdr_,type_) ((hdr_) |= ((type_)<<27))
719 #define OSAPI_LOGDATA_GET_TYPE(hdr_) (((hdr_)>>27) & 0xf)
720 
721 #if OSAPI_ENABLE_TRACE
722 typedef enum
723 {
724  OSAPI_TRACETYPE_HEADER,
725  OSAPI_TRACETYPE_INT32,
726  OSAPI_TRACETYPE_STRING,
727  OSAPI_TRACETYPE_GUID,
728  OSAPI_TRACETYPE_V4_AS_INT32,
729  OSAPI_TRACETYPE_V12_AS_INT32
730 } OSAPI_TraceType_T;
731 #endif
732 
733 /*ci
734  * \brief A log-entry in the log-buffer
735  *
736  * \details
737  * Each log-entry in the log-buffer has a fixed sized buffer followed
738  * by a variable length part that depends on the log-information stored.
739  * The following notation is commonly used in the code:
740  *
741  * data_ptr = (char*)&log_entry[1]
742  *
743  * The data-pointer now points to the beginning of the variable length
744  * data part that follows the fixed size header.
745  *
746  * \verbatim
747  * +-----------------+ Log-buffer
748  * | OSAPI_LogEntry |
749  * | |
750  * +- - - - - - - - -+ <- data_ptr
751  * | |
752  * | log-data |
753  * | |
754  * +-----------------+ Log-buffer
755  * | OSAPI_LogEntry |
756  * | |
757  * +- - - - - - - - -+
758  * | |
759  * | log-data |
760  * | |
761  * +-----------------+
762  *
763  * \endverbatim
764  */
765 typedef struct OSAPI_LogEntry
766 {
767  /*ci
768  * \brief time this message was logged
769  */
770  OSAPI_NtpTime timestamp;
771 
772  /*ci
773  * \brief The error code
774  */
775  RTI_UINT32 error_code;
776 
777 } OSAPI_LogEntry_T;
778 
779 /*ce
780  * \ingroup OSAPILogClass
781  * \brief Logging verbosity
782  */
783 typedef enum
784 {
785  /*ce \brief Logs are not written
786  */
788 
789  /*ce \brief Only error logs are written
790  */
792 
793  /*ce \brief Error and warning logs are written
794  */
796 
797  /*ce \brief All logs are written
798  */
801 
802 /*ce
803  * \ingroup OSAPILogClass
804  * \brief Optional user-defined function to output a log/trace buffer
805  *
806  * The handler is set by OSAPI_Log_set_property().
807  *
808  * \param[in] buffer Pointer to buffer with log to write
809  * \param[in] length Length of the buffer to write
810  */
811 typedef void
812 (*OSAPI_Log_write_buffer_T)(const char *buffer,RTI_INT32 length);
813 
814 /*ce
815  * \ingroup OSAPILogClass
816  * \brief Configuration of logging functionality
817  */
819 {
820  /*ce
821  *
822  * \brief The maximum number of bytes allocated to the log buffer.
823  *
824  * \details
825  * Log entries are of variable length. When this limit has been reached,
826  * no more log entries can be stored unless the buffer is cleared.
827  */
828  RTI_SIZE_T max_buffer_size;
829 
830  /*ce \brief Bitmap to control the fidelity of what is stored in the log
831  * entry
832  */
833  RTI_UINT32 log_detail;
834 
835  /*ce \brief Function pointer to output a log/trace buffer
836  */
838 };
839 
840 
841 #define OSAPI_LOG_DETAIL_MODULENAME (0x80000000UL)
842 #define OSAPI_LOG_DETAIL_SOURCEFILE (0x40000000UL)
843 #define OSAPI_LOG_DETAIL_LINENUMBER (0x20000000UL)
844 #define OSAPI_LOG_DETAIL_FUNCTIONAME (0x10000000UL)
845 #define OSAPI_LOG_DETAIL_FORMAT (0x08000000UL)
846 #define OSAPI_LOG_DETAIL_DATA_ONLY (0x04000000UL)
847 
848 #define OSAPI_LOG_DETAIL_ALL \
849  (OSAPI_LOG_DETAIL_MODULENAME | \
850  OSAPI_LOG_DETAIL_SOURCEFILE | \
851  OSAPI_LOG_DETAIL_LINENUMBER | \
852  OSAPI_LOG_DETAIL_FUNCTIONAME | \
853  OSAPI_LOG_DETAIL_FORMAT | \
854  OSAPI_LOG_DETAIL_DATA_ONLY)
855 
856 #define OSAPI_LOG_DETAIL_NO_DATA \
857  (OSAPI_LOG_DETAIL_MODULENAME | \
858  OSAPI_LOG_DETAIL_SOURCEFILE | \
859  OSAPI_LOG_DETAIL_LINENUMBER | \
860  OSAPI_LOG_DETAIL_FUNCTIONAME )
861 
862 #if OSAPI_ENABLE_PRECONDITION
863 #define OSAPI_LOG_BUFFER_SIZE (16384)
864 #else
865 #define OSAPI_LOG_BUFFER_SIZE (128)
866 #endif
867 
868 #define OSAPI_LogProperty_INIITALIZER \
869 {\
870  OSAPI_LOG_BUFFER_SIZE,\
871  OSAPI_LOG_DETAIL_ALL,\
872  NULL\
873 }
874 
875 #if OSAPI_ENABLE_TRACE
876 typedef void
877 (*OSAPI_TraceHandler_T)(RTI_UINT32 trace_mask,
878  void *param,
879  RTI_INT32 context,
880  const char *const module,
881  const char *const file,
882  const char *const function,
883  RTI_INT32 line_no,
884  OSAPI_TraceType_T type,
885  const void *title,
886  RTI_INT32 int_value,
887  const void *ptr_value,
888  const char *str_value,
889  RTI_BOOL is_final);
890 
891 OSAPIDllVariable extern OSAPI_TraceHandler_T OSAPI_gv_TraceFunction;
892 OSAPIDllVariable extern void* OSAPI_gv_TraceFunctionParam;
893 OSAPIDllVariable extern RTI_UINT32 OSAPI_gv_TraceMask;
894 #endif
895 
896 /*ce
897  * \ingroup OSAPILogClass
898  * \brief Optional user-defined function for processing new log messages
899  *
900  * \details Definition of a function that can be installed with the logger and
901  * that will be called for each new log event.
902  *
903  * The handler is set by OSAPI_Log_set_log_handler().
904  *
905  * When called, provides parameters containing the raw log entry and additional
906  * optional information.
907  *
908  *
909  * \param[in] param User-defined payload
910  * \param[in] msg Log entry
911  * \param[in] kind Kind of log message
912  * \param[in] ec Unique error code of log message
913  * \param[in] module Module of log message
914  * \param[in] file Name of source file. Optional.
915  * \param[in] func Name of function. Optional.
916  * \param[in] line Line number. Optional.
917  * \param[in] argc Variable length argument count
918  * \param[in] ap Variable length argument list
919  */
920 typedef void
921 (*OSAPI_LogHandler_T)(void *param,OSAPI_LogEntry_T *entry);
922 
923 typedef void
924 (*OSAPI_LogDisplay_T)(void *param,OSAPI_LogEntry_T *msg);
925 
926 OSAPIDllVariable extern OSAPI_LogHandler_T OSAPI_gv_LogFunction;
927 OSAPIDllVariable extern void* OSAPI_gv_LogFunctionParam;
928 
929 OSAPIDllVariable extern OSAPI_LogDisplay_T OSAPI_gv_LogDisplayFunction;
930 OSAPIDllVariable extern void* OSAPI_gv_LogDisplayFunctionParam;
931 
932 /*ce
933  * \ingroup OSAPILogClass
934  * \brief Install a log handler
935  *
936  * \details
937  * The log functionality allows the user to specify a log handler. The log
938  * handler is a function which is called for every logged event. It is up
939  * to the user to decide what to do with the log message. The handler is
940  * a global function pointer.
941  *
942  * \param [in] handler Pointer to log handler function
943  * \param [in] param Parameter passed to the log handler function. This
944  * parameter is transparent to the log functionality.
945  *
946  * \return RTI_TRUE on success, RTI_FALSE on failure
947  *
948  */
949 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
950 OSAPI_Log_set_log_handler(OSAPI_LogHandler_T handler,void *param);
951 
952 /*ce
953  * \ingroup OSAPILogClass
954  * \brief Return the current log handler
955  *
956  * \details
957  * Return the current log handler.
958  *
959  * \param [in] handler Pointer to store log handler function
960  * \param [in] param Pointer to store the current log handler parameter.
961  *
962  * \return RTI_TRUE on success, RTI_FALSE on failure
963  *
964  */
965 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
966 OSAPI_Log_get_log_handler(OSAPI_LogHandler_T *handler,void **param);
967 
968 #if OSAPI_ENABLE_TRACE
969 /*ce
970  * \ingroup OSAPILogClass
971  * \brief Install a trace handler
972  *
973  * \details
974  * Install a custom trace handler. Traces are not stored in the log-buffer
975  * and is generally used to analyze behavior interactively. the default
976  * trace handler outputs the trace data to a console.
977  *
978  * \param [in] handler Pointer to trace handler function
979  * \param [in] param Parameter passed to the trace handler function. This
980  * parameter is transparent to the trace functionality.
981  *
982  * \return RTI_TRUE on success, RTI_FALSE on failure
983  *
984  */
985 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
986 OSAPI_Log_set_trace_handler(OSAPI_TraceHandler_T handler,void *param);
987 
988 /*ce
989  * \brief Return the trace handler
990  * \ingroup OSAPILogClass
991  *
992  * \details
993  * Return the current trace handler and trace parameter. This information
994  * can be used to daisy-chain calls to multiple trace-handlers.
995  *
996  * \param [in] handler Pointer to store trace handler function
997  * \param [in] param Pointer to store the trace handler parameter.
998  *
999  * \return RTI_TRUE on success, RTI_FALSE on failure
1000  *
1001  */
1002 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
1003 OSAPI_Log_get_trace_handler(OSAPI_TraceHandler_T *handler,void **param);
1004 #endif
1005 
1006 /*ce
1007  * \ingroup OSAPILogClass
1008  * \brief Install a display handler
1009  *
1010  * \details
1011  * The display handler is responsible for outputting log messages to a console.
1012  *
1013  * \param [in] handler Pointer to display function
1014  * \param [in] param Parameter passed to the display handler function. This
1015  * parameter is transparent to the log functionality.
1016  *
1017  * \return RTI_TRUE on success, RTI_FALSE on failure
1018  *
1019  */
1020 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
1021 OSAPI_Log_set_display_handler(OSAPI_LogDisplay_T handler,void *param);
1022 
1023 /*ce
1024  * \brief Return the current display function
1025  * \ingroup OSAPILogClass
1026  *
1027  * \details
1028  * Return the current log handler.
1029  *
1030  * \param [in] handler Pointer to store display handler function
1031  * \param [in] param Pointer to store the current display handler parameters.
1032  *
1033  * \return RTI_TRUE on success, RTI_FALSE on failure
1034  *
1035  */
1036 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
1037 OSAPI_Log_get_display_handler(OSAPI_LogDisplay_T *handler,void **param);
1038 
1039 /*ci
1040  * \brief Initialize the log functionality
1041  * \ingroup OSAPILogClass
1042  *
1043  * \details
1044  * Dynamically allocates bytes for the log ring buffer. Also prints out endianness.
1045  * If store_debug_logs is false, debug-level logs are printed to the console.
1046  * 0Otherwise, the logs are stored in the log buffer.
1047  * The log functionality must be initialized before any log messages can be
1048  * stored. It should only be called once. Since debug logs can easily exhaust
1049  * the log buffer, it can optionally be enabled. However, even if debug
1050  * logging is disabled, the log handler function still has the option
1051  * to store it.
1052  *
1053  * \return RTI_TRUE on success, RTI_FALSE on failure
1054  */
1055 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
1056 OSAPI_Log_initialize(void);
1057 
1058 /*ci
1059  * \ingroup OSAPILogClass
1060  * \brief Finalize the log buffer
1061  *
1062  * \details
1063  * This function release all memory allocated to the log buffer and release
1064  * all resources associated with it.
1065  *
1066  * \return RTI_TRUE on success, RTI_FALSE on failure
1067  *
1068  * \sa \ref OSAPI_Log_initialize
1069  */
1070 SHOULD_CHECK_RETURN OSAPIDllExport RTI_BOOL
1071 OSAPI_Log_finalize(void);
1072 
1073 /*ce
1074  * \ingroup OSAPILogClass
1075  * \brief Set the log verbosity
1076  *
1077  * \details
1078  * Change the log verbosity. The new setting takes immediate effect.
1079  *
1080  * \param [in] verbosity New log verbosity
1081  *
1082  */
1083 OSAPIDllExport void
1085 
1086 #if OSAPI_ENABLE_TRACE
1087 /*ce
1088  * \ingroup OSAPILogClass
1089  * \brief Set the trace mask
1090  *
1091  * \param [in] mask New trace mask
1092  */
1093 OSAPIDllExport void
1094 OSAPI_Trace_set_trace_mask(RTI_UINT32 mask);
1095 #endif
1096 
1097 /*ce
1098  * \ingroup OSAPILogClass
1099  * \brief Clear the log buffer
1100  *
1101  * \details
1102  * Clear the log buffer, all the current entries are lost
1103  *
1104  * \return RTI_TRUE on success, RTI_FALSE on failure
1105  */
1106 SHOULD_CHECK_RETURN OSAPIDllExport RTI_BOOL
1107 OSAPI_Log_clear(void);
1108 
1109 /*ce
1110  * \brief Returns the error code for a function that failed
1111  * \ingroup OSAPILogClass
1112  *
1113  * \details
1114  * Many functions returns RTI_FALSE or NULL on failure. In order to provide
1115  * additional information about reason for the failure fucntions may set
1116  * an additional error code. This function returns the last error-code
1117  * recorded for the calling thread.
1118  *
1119  * \return Last error-code recorded for this thread
1120  *
1121  */
1122 OSAPIDllExport RTI_INT32
1124 
1125 /*ce
1126  * \brief Get the current log properties
1127  * \ingroup OSAPILogClass
1128  *
1129  * \details
1130  * Return the current log properties
1131  *
1132  * \param[out] property - Current log properties
1133  *
1134  * \sa OSAPI_Log_set_property
1135  */
1136 OSAPIDllExport void
1137 OSAPI_Log_get_property(struct OSAPI_LogProperty *property);
1138 
1139 /*ce
1140  * \brief Set the log properties
1141  * \ingroup OSAPILogClass
1142  *
1143  * \details
1144  * Set the current log properties. It is not possible to set new
1145  * properties after OSAPI_Log_initialize() has been called/
1146  *
1147  * \param[in] property New log properties
1148  *
1149  * \return RTI_TRUE if new properties can be set, RTI_FALSE otherwise
1150  * \sa OSAPI_Log_get_property
1151  */
1152 OSAPIDllExport RTI_BOOL
1153 OSAPI_Log_set_property(struct OSAPI_LogProperty *property);
1154 
1155 /*ci
1156  * \brief Get the current log verbosity
1157  * \ingroup OSAPILogClass
1158  *
1159  * \return Current verbosity
1160  */
1161 OSAPIDllExport OSAPI_LogVerbosity_T
1162 OSAPI_Log_get_verbosity(void);
1163 
1164 /*ci
1165  * \brief Create a new log-entry
1166  *
1167  * \ingroup OSAPILogClass
1168  *
1169  * \param[in] kind The type of log entry
1170  * \param[in] error_code The error-code
1171  * \param[in] module The name of the module logging the error
1172  * \param[in] file The file logging the error
1173  * \param[in] line The line number in file the error is logged
1174  * \param[in] is_final If RTI_TRUE more data follows, if RTI_FALSE then
1175  * the log meesage is considered complete.
1176  */
1177 OSAPIDllExport void
1178 OSAPI_Log_entry_create(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1179  const char *const module, const char *const file,
1180  const char *const func, RTI_INT32 line,RTI_BOOL is_final);
1181 
1182 /*ci
1183  * \brief Add an integer to a log-entry
1184  *
1185  * \ingroup OSAPILogClass
1186  *
1187  * \param[in] name The name of the integer being logged
1188  * \param[in] value The value of the integer being logged
1189  * \param[in] is_final RTI_TRUE if this is the last value added to the log entry
1190  * RTI_FALSE if more values are being added to the log entry
1191  */
1192 OSAPIDllExport void
1193 OSAPI_Log_entry_add_int(const char *name,RTI_INT32 value,RTI_BOOL is_final);
1194 
1195 /*ci
1196  * \brief Add a string to a log-entry
1197  *
1198  * \ingroup OSAPILogClass
1199  *
1200  * \param[in] name The name of the string being logged
1201  * \param[in] value The value of the string being logged
1202  * \param[in] is_final RTI_TRUE if this is the last value added to the log entry
1203  * RTI_FALSE if more values are being added to the log entry
1204  */
1205 OSAPIDllExport void
1206 OSAPI_Log_entry_add_string(const char *name,const char *value,RTI_BOOL is_final);
1207 
1208 
1209 /*ci
1210  * \brief Add a pointer to a log-entry
1211  *
1212  * \ingroup OSAPILogClass
1213  *
1214  * \param[in] name The name of the pointer being logged
1215  * \param[in] value The value of the pointer being logged
1216  * \param[in] is_final RTI_TRUE if this is the last value added to the log entry
1217  * RTI_FALSE if more values are being added to the log entry
1218  */
1219 OSAPIDllExport void
1220 OSAPI_Log_entry_add_pointer(const char *name,const void *value,RTI_BOOL is_final);
1221 
1222 OSAPIDllExport RTI_BOOL
1223 OSAPI_Log_entry_get_data(OSAPI_LogEntry_T *log_entry,char **data_ptr,
1224  OSAPI_LogType_T *type,const char **name,
1225  const void **value,RTI_BOOL *is_final);
1226 
1227 /*ci
1228  * \brief Create a new log-entry for an error-code with no additional data
1229  *
1230  * \ingroup OSAPILogClass
1231  *
1232  * \param[in] kind The type of log entry
1233  * \param[in] error_code The error-code
1234  * \param[in] module The name of the module logging the error
1235  * \param[in] file The file logging the error
1236  * \param[in] line The line number in file the error is logged
1237  *
1238  * \sa OSAPI_Log_entry_create
1239  */
1240 OSAPIDllExport void
1241 OSAPI_Log_entry_add(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1242  const char *const module, const char *const file,
1243  const char *const func, RTI_INT32 line);
1244 
1245 /*ci
1246  * \brief Create a new log-entry with a single integer
1247  *
1248  * \ingroup OSAPILogClass
1249  *
1250  * \param[in] kind The type of log entry
1251  * \param[in] error_code The error-code
1252  * \param[in] module The name of the module logging the error
1253  * \param[in] file The file logging the error
1254  * \param[in] line The line number in file the error is logged
1255  * \param[in] name The name of the integer being logged
1256  * \param[in] value The value of the integer being logged
1257  *
1258  */
1259 OSAPIDllExport void
1260 OSAPI_Log_entry_add_1int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1261  const char *const module, const char *const file,
1262  const char *const func, RTI_INT32 line,const char *name,
1263  RTI_INT32 value);
1264 
1265 
1266 /*ci
1267  * \brief Create a new log-entry with a 2 integers
1268  *
1269  * \ingroup OSAPILogClass
1270  *
1271  * \param[in] kind The type of log entry
1272  * \param[in] error_code The error-code
1273  * \param[in] module The name of the module logging the error
1274  * \param[in] file The file logging the error
1275  * \param[in] line The line number in file the error is logged
1276  * \param[in] name1 The name of the 1st integer being logged
1277  * \param[in] value1 The value of the 1st integer being logged
1278  * \param[in] name2 The name of the 2nd integer being logged
1279  * \param[in] value2 The value of the 2nd integer being logged
1280  *
1281  */
1282 OSAPIDllExport void
1283 OSAPI_Log_entry_add_2int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1284  const char *const module, const char *const file,
1285  const char *const func, RTI_INT32 line,
1286  const char *name1,RTI_INT32 value1,
1287  const char *name2,RTI_INT32 value2);
1288 
1289 /*ci
1290  * \brief Create a new log-entry with a 3 integers
1291  *
1292  * \ingroup OSAPILogClass
1293  *
1294  * \param[in] kind The type of log entry
1295  * \param[in] error_code The error-code
1296  * \param[in] module The name of the module logging the error
1297  * \param[in] file The file logging the error
1298  * \param[in] line The line number in file the error is logged
1299  * \param[in] name1 The name of the 1st integer being logged
1300  * \param[in] value1 The value of the 1st integer being logged
1301  * \param[in] name2 The name of the 2nd integer being logged
1302  * \param[in] value2 The value of the 2nd integer being logged
1303  * \param[in] name3 The name of the 3rd integer being logged
1304  * \param[in] value3 The value of the 3rd integer being logged
1305  *
1306  */
1307 OSAPIDllExport void
1308 OSAPI_Log_entry_add_3int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1309  const char *const module, const char *const file,
1310  const char *const func, RTI_INT32 line,
1311  const char *name1,RTI_INT32 value1,
1312  const char *name2,RTI_INT32 value2,
1313  const char *name3,RTI_INT32 value3);
1314 
1315 /*ci
1316  * \brief Create a new log-entry with a single string
1317  *
1318  * \ingroup OSAPILogClass
1319  *
1320  * \param[in] kind The type of log entry
1321  * \param[in] error_code The error-code
1322  * \param[in] module The name of the module logging the error
1323  * \param[in] file The file logging the error
1324  * \param[in] line The line number in file the error is logged
1325  * \param[in] name The name of the string being logged
1326  * \param[in] value The value of the string being logged
1327  *
1328  */
1329 OSAPIDllExport void
1330 OSAPI_Log_entry_add_1string(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1331  const char *const module, const char *const file,
1332  const char *const func, RTI_INT32 line,
1333  const char *name,const char* value);
1334 
1335 /*ci
1336  * \brief Create a new log-entry with a 2 strings
1337  *
1338  * \ingroup OSAPILogClass
1339  *
1340  * \param[in] kind The type of log entry
1341  * \param[in] error_code The error-code
1342  * \param[in] module The name of the module logging the error
1343  * \param[in] file The file logging the error
1344  * \param[in] line The line number in file the error is logged
1345  * \param[in] name1 The name of the 1st string being logged
1346  * \param[in] value1 The value of the 1st string being logged
1347  * \param[in] name2 The name of the 2nd string being logged
1348  * \param[in] value2 The value of the 2nd string being logged
1349  *
1350  */
1351 OSAPIDllExport void
1352 OSAPI_Log_entry_add_2string(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1353  const char *const module, const char *const file,
1354  const char *const func, RTI_INT32 line,
1355  const char *name1,const char* value1,
1356  const char *name2,const char* value2);
1357 
1358 /*ci
1359  * \brief Create a new log-entry with a single pointer
1360  *
1361  * \ingroup OSAPILogClass
1362  *
1363  * \param[in] kind The type of log entry
1364  * \param[in] error_code The error-code
1365  * \param[in] module The name of the module logging the error
1366  * \param[in] file The file logging the error
1367  * \param[in] line The line number in file the error is logged
1368  * \param[in] name The name of the pointer being logged
1369  * \param[in] value The value of the pointer being logged
1370  *
1371  */
1372 OSAPIDllExport void
1373 OSAPI_Log_entry_add_1pointer(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1374  const char *const module, const char *const file,
1375  const char *const func, RTI_INT32 line,
1376  const char *name, const void* value);
1377 
1378 /*ci
1379  * \brief Create a new log-entry with a single string and a integer
1380  *
1381  * \ingroup OSAPILogClass
1382  *
1383  * \param[in] kind The type of log entry
1384  * \param[in] error_code The error-code
1385  * \param[in] module The name of the module logging the error
1386  * \param[in] file The file logging the error
1387  * \param[in] line The line number in file the error is logged
1388  * \param[in] s_name The name of the string being logged
1389  * \param[in] s_value The value of the string being logged
1390  * \param[in] i_name The name of the integer being logged
1391  * \param[in] i_value The value of the string being logged
1392  */
1393 OSAPIDllExport void
1394 OSAPI_Log_entry_add_1string_1int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1395  const char *const module, const char *const file,
1396  const char *const func, RTI_INT32 line,
1397  const char *s_name,const char* s_value,
1398  const char *i_name,RTI_INT32 i_value);
1399 #endif /* OSAPI_ENABLE_LOG */
1400 
1401 /*ci
1402  * \brief Convert an integer to a string in decimal format
1403  * *
1404  * \param[inout] buffer Buffer to store result in
1405  * \param[in] max_length Maximum length of the buffer
1406  * \param[in] d The digit to convert
1407  *
1408  * \return The number of characters placed in the buffer excluding the
1409  * NULL termination. If there is insufficient space max_length
1410  * is returned.
1411  */
1412 OSAPIDllExport RTI_INT32
1413 OSAPI_Log_itoa(char *buffer,RTI_INT32 max_length,RTI_INT32 d);
1414 
1415 #ifdef __cplusplus
1416 } /* extern "C" */
1417 #endif
1418 
1419 #include "osapi/osapi_log_impl.h"
1420 
1421 #endif /* osapi_log_h */

RTI Connext DDS Micro Version 2.4.10 Copyright © Fri Jun 30 2017 Real-Time Innovations, Inc