RTI Connext DDS Micro  Version 2.4.8
 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 thread_id thread id of the thread that logged this
769  * message
770  */
771  OSAPI_ThreadId thread_id;
772 
773  /*ci
774  * \brief time this message was logged
775  */
776  OSAPI_NtpTime timestamp;
777 
778  /*ci
779  * \brief The error code
780  */
781  RTI_UINT32 error_code;
782 
783 } OSAPI_LogEntry_T;
784 
785 /*e
786  */
787 typedef enum
788 {
789  /* e \dref_LogVerbosity_OSAPI_LOG_VERBOSITY_SILENT */
790  OSAPI_LOG_VERBOSITY_SILENT = 0,
791  /* e \dref_LogVerbosity_OSAPI_LOG_VERBOSITY_ERROR */
792  OSAPI_LOG_VERBOSITY_ERROR = 1,
793  /* e \dref_LogVerbosity_OSAPI_LOG_VERBOSITY_WARNING */
794  OSAPI_LOG_VERBOSITY_WARNING = 2,
795  /* e \dref_LogVerbosity_OSAPI_LOG_VERBOSITY_DEBUG */
796  OSAPI_LOG_VERBOSITY_DEBUG = 3
797 } OSAPI_LogVerbosity_T;
798 
799 typedef void
800 (*OSAPI_Log_write_buffer_T)(const char *buffer,RTI_INT32 length);
801 
802 /*ce
803  * \ingroup OSAPILogClass
804  * \brief Configuration of logging functionality
805  */
807 {
808  /*ce
809  *
810  * \brief The maximum number of bytes allocated to the log buffer.
811  *
812  * \details
813  * Log entries are of variable length. When this limit has been reached,
814  * no more log entries can be stored unless the buffer is cleared.
815  */
816  RTI_SIZE_T max_buffer_size;
817 
818  /*ce \brief Bitmap to control the fidelity of what is stored in the log
819  * entry
820  */
821  RTI_UINT32 log_detail;
822 
823  /*ce \brief Function pointer to output a log/trace buffer
824  */
825  OSAPI_Log_write_buffer_T write_buffer;
826 };
827 
828 
829 #define OSAPI_LOG_DETAIL_MODULENAME (0x80000000UL)
830 #define OSAPI_LOG_DETAIL_SOURCEFILE (0x40000000UL)
831 #define OSAPI_LOG_DETAIL_LINENUMBER (0x20000000UL)
832 #define OSAPI_LOG_DETAIL_FUNCTIONAME (0x10000000UL)
833 #define OSAPI_LOG_DETAIL_FORMAT (0x08000000UL)
834 #define OSAPI_LOG_DETAIL_DATA_ONLY (0x04000000UL)
835 
836 #define OSAPI_LOG_DETAIL_ALL \
837  (OSAPI_LOG_DETAIL_MODULENAME | \
838  OSAPI_LOG_DETAIL_SOURCEFILE | \
839  OSAPI_LOG_DETAIL_LINENUMBER | \
840  OSAPI_LOG_DETAIL_FUNCTIONAME | \
841  OSAPI_LOG_DETAIL_FORMAT | \
842  OSAPI_LOG_DETAIL_DATA_ONLY)
843 
844 #define OSAPI_LOG_DETAIL_NO_DATA \
845  (OSAPI_LOG_DETAIL_MODULENAME | \
846  OSAPI_LOG_DETAIL_SOURCEFILE | \
847  OSAPI_LOG_DETAIL_LINENUMBER | \
848  OSAPI_LOG_DETAIL_FUNCTIONAME )
849 
850 #if OSAPI_ENABLE_PRECONDITION
851 #define OSAPI_LOG_BUFFER_SIZE (16384)
852 #else
853 #define OSAPI_LOG_BUFFER_SIZE (128)
854 #endif
855 
856 #define OSAPI_LogProperty_INIITALIZER \
857 {\
858  OSAPI_LOG_BUFFER_SIZE,\
859  OSAPI_LOG_DETAIL_ALL,\
860  NULL\
861 }
862 
863 #if OSAPI_ENABLE_TRACE
864 typedef void
865 (*OSAPI_TraceHandler_T)(RTI_UINT32 trace_mask,
866  void *param,
867  RTI_INT32 context,
868  const char *const module,
869  const char *const file,
870  const char *const function,
871  RTI_INT32 line_no,
872  OSAPI_TraceType_T type,
873  const void *title,
874  RTI_INT32 int_value,
875  const void *ptr_value,
876  const char *str_value,
877  RTI_BOOL is_final);
878 
879 OSAPIDllVariable extern OSAPI_TraceHandler_T OSAPI_gv_TraceFunction;
880 OSAPIDllVariable extern void* OSAPI_gv_TraceFunctionParam;
881 OSAPIDllVariable extern RTI_UINT32 OSAPI_gv_TraceMask;
882 #endif
883 
884 /*ce
885  * \ingroup OSAPILogClass
886  * \brief Optional user-defined function for processing new log messages
887  *
888  * \details Definition of a function that can be installed with the logger and
889  * that will be called for each new log event.
890  *
891  * The handler is set by OSAPI_Log_set_log_handler.
892  *
893  * When called, provides parameters containing the raw log entry and additional
894  * optional information.
895  *
896  *
897  * \param[in] param User-defined payload
898  * \param[in] msg Log entry
899  * \param[in] kind Kind of log message
900  * \param[in] ec Unique error code of log message
901  * \param[in] module Module of log message
902  * \param[in] file Name of source file. Optional.
903  * \param[in] func Name of function. Optional.
904  * \param[in] line Line number. Optional.
905  * \param[in] argc Variable length argument count
906  * \param[in] ap Variable length argument list
907  */
908 typedef void
909 (*OSAPI_LogHandler_T)(void *param,OSAPI_LogEntry_T *entry);
910 
911 typedef void
912 (*OSAPI_LogDisplay_T)(void *param,OSAPI_LogEntry_T *msg);
913 
914 OSAPIDllVariable extern OSAPI_LogHandler_T OSAPI_gv_LogFunction;
915 OSAPIDllVariable extern void* OSAPI_gv_LogFunctionParam;
916 
917 OSAPIDllVariable extern OSAPI_LogDisplay_T OSAPI_gv_LogDisplayFunction;
918 OSAPIDllVariable extern void* OSAPI_gv_LogDisplayFunctionParam;
919 
920 /*ce
921  * \ingroup OSAPILogClass
922  * \brief Install a log handler
923  *
924  * \details
925  * The log functionality allows the user to specify a log handler. The log
926  * handler is a function which is called for every logged event. It is up
927  * to the user to decide what to do with the log message. The handler is
928  * a global function pointer.
929  *
930  * \param [in] handler Pointer to log handler function
931  * \param [in] param Parameter passed to the log handler function. This
932  * parameter is transparent to the log functionality.
933  *
934  * \return RTI_TRUE on success, RTI_FALSE on failure
935  *
936  */
937 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
938 OSAPI_Log_set_log_handler(OSAPI_LogHandler_T handler,void *param);
939 
940 /*ce
941  * \ingroup OSAPILogClass
942  * \brief Return the current log handler
943  *
944  * \details
945  * Return the current log handler.
946  *
947  * \param [in] handler Pointer to store log handler function
948  * \param [in] param Pointer to store the current log handler parameter.
949  *
950  * \return RTI_TRUE on success, RTI_FALSE on failure
951  *
952  */
953 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
954 OSAPI_Log_get_log_handler(OSAPI_LogHandler_T *handler,void **param);
955 
956 #if OSAPI_ENABLE_TRACE
957 /*ce
958  * \ingroup OSAPILogClass
959  * \brief Install a trace handler
960  *
961  * \details
962  * Install a custom trace handler. Traces are not stored in the log-buffer
963  * and is generally used to analyze behavior interactively. the default
964  * trace handler outputs the trace data to a console.
965  *
966  * \param [in] handler Pointer to trace handler function
967  * \param [in] param Parameter passed to the trace handler function. This
968  * parameter is transparent to the trace functionality.
969  *
970  * \return RTI_TRUE on success, RTI_FALSE on failure
971  *
972  */
973 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
974 OSAPI_Log_set_trace_handler(OSAPI_TraceHandler_T handler,void *param);
975 
976 /*ce
977  * \brief Return the trace handler
978  * \ingroup OSAPILogClass
979  *
980  * \details
981  * Return the current trace handler and trace parameter. This information
982  * can be used to daisy-chain calls to multiple trace-handlers.
983  *
984  * \param [in] handler Pointer to store trace handler function
985  * \param [in] param Pointer to store the trace handler parameter.
986  *
987  * \return RTI_TRUE on success, RTI_FALSE on failure
988  *
989  */
990 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
991 OSAPI_Log_get_trace_handler(OSAPI_TraceHandler_T *handler,void **param);
992 #endif
993 
994 /*ce
995  * \ingroup OSAPILogClass
996  * \brief Install a display handler
997  *
998  * \details
999  * The display handler is responsible for outputting log messages to a console.
1000  *
1001  * \param [in] handler Pointer to display function
1002  * \param [in] param Parameter passed to the display handler function. This
1003  * parameter is transparent to the log functionality.
1004  *
1005  * \return RTI_TRUE on success, RTI_FALSE on failure
1006  *
1007  */
1008 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
1009 OSAPI_Log_set_display_handler(OSAPI_LogDisplay_T handler,void *param);
1010 
1011 /*ce
1012  * \brief Return the current display function
1013  * \ingroup OSAPILogClass
1014  *
1015  * \details
1016  * Return the current log handler.
1017  *
1018  * \param [in] handler Pointer to store display handler function
1019  * \param [in] param Pointer to store the current display handler parameters.
1020  *
1021  * \return RTI_TRUE on success, RTI_FALSE on failure
1022  *
1023  */
1024 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
1025 OSAPI_Log_get_display_handler(OSAPI_LogDisplay_T *handler,void **param);
1026 
1027 /*ce
1028  * \brief Initialize the log functionality
1029  * \ingroup OSAPILogClass
1030  *
1031  * \details
1032  * Dynamically allocates bytes for the log ring buffer. Also prints out endianness.
1033  * If store_debug_logs is false, debug-level logs are printed to the console.
1034  * 0Otherwise, the logs are stored in the log buffer.
1035  * The log functionality must be initialized before any log messages can be
1036  * stored. It should only be called once. Since debug logs can easily exhaust
1037  * the log buffer, it can optionally be enabled. However, even if debug
1038  * logging is disabled, the log handler function still has the option
1039  * to store it.
1040  *
1041  * \return RTI_TRUE on success, RTI_FALSE on failure
1042  */
1043 MUST_CHECK_RETURN OSAPIDllExport RTI_BOOL
1044 OSAPI_Log_initialize(void);
1045 
1046 /*ce
1047  * \ingroup OSAPILogClass
1048  * \brief Finalize the log buffer
1049  *
1050  * \details
1051  * This function release all memory allocated to the log buffer and release
1052  * all resources associated with it.
1053  *
1054  * \return RTI_TRUE on success, RTI_FALSE on failure
1055  *
1056  * \sa \ref OSAPI_Log_initialize
1057  */
1058 SHOULD_CHECK_RETURN OSAPIDllExport RTI_BOOL
1059 OSAPI_Log_finalize(void);
1060 
1061 /*ce
1062  * \ingroup OSAPILogClass
1063  * \brief Set the log verbosity
1064  *
1065  * \details
1066  * Change the log verbosity. The new setting takes immediate effect.
1067  *
1068  * \param [in] verbosity New log verbosity
1069  *
1070  */
1071 OSAPIDllExport void
1072 OSAPI_Log_set_verbosity(OSAPI_LogVerbosity_T verbosity);
1073 
1074 #if OSAPI_ENABLE_TRACE
1075 /*ce
1076  * \ingroup OSAPILogClass
1077  * \brief Set the trace mask
1078  *
1079  * \param [in] mask New trace mask
1080  */
1081 OSAPIDllExport void
1082 OSAPI_Trace_set_trace_mask(RTI_UINT32 mask);
1083 #endif
1084 
1085 /*ce
1086  * \ingroup OSAPILogClass
1087  * \brief Clear the log buffer
1088  *
1089  * \details
1090  * Clear the log buffer, all the current entries are lost
1091  *
1092  * \return RTI_TRUE on success, RTI_FALSE on failure
1093  */
1094 SHOULD_CHECK_RETURN OSAPIDllExport RTI_BOOL
1095 OSAPI_Log_clear(void);
1096 
1097 /*ce
1098  * \brief Returns the error code for a function that failed
1099  * \ingroup OSAPILogClass
1100  *
1101  * \details
1102  * Many functions returns RTI_FALSE or NULL on failure. In order to provide
1103  * additional information about reason for the failure fucntions may set
1104  * an additional error code. This function returns the last error-code
1105  * recorded for the calling thread.
1106  *
1107  * \return Last error-code recorded for this thread
1108  *
1109  */
1110 OSAPIDllExport RTI_INT32
1112 
1113 /*ci
1114  * \brief Get the current log properties
1115  * \ingroup OSAPILogClass
1116  *
1117  * \details
1118  * Return the current log properties
1119  *
1120  * \param[out] property - Current log properties
1121  *
1122  * \sa OSAPI_Log_set_property
1123  */
1124 OSAPIDllExport void
1125 OSAPI_Log_get_property(struct OSAPI_LogProperty *property);
1126 
1127 /*ci
1128  * \brief Set the log properties
1129  * \ingroup OSAPILogClass
1130  *
1131  * \details
1132  * Set the current log properties. It is not possible to set new
1133  * properties after OSAPI_Log_initialize() has been called/
1134  *
1135  * \param[in] property New log properties
1136  *
1137  * \return RTI_TRUE if new properties can be set, RTI_FALSE otherwise
1138  * \sa OSAPI_Log_get_property
1139  */
1140 OSAPIDllExport RTI_BOOL
1141 OSAPI_Log_set_property(struct OSAPI_LogProperty *property);
1142 
1143 /*ci
1144  * \brief Get the current log verbosity
1145  * \ingroup OSAPILogClass
1146  *
1147  * \return Current verbosity
1148  */
1149 OSAPIDllExport OSAPI_LogVerbosity_T
1150 OSAPI_Log_get_verbosity(void);
1151 
1152 /*ci
1153  * \brief Create a new log-entry
1154  *
1155  * \ingroup OSAPILogClass
1156  *
1157  * \param[in] kind The type of log entry
1158  * \param[in] error_code The error-code
1159  * \param[in] module The name of the module logging the error
1160  * \param[in] file The file logging the error
1161  * \param[in] line The line number in file the error is logged
1162  * \param[in] is_final If RTI_TRUE more data follows, if RTI_FALSE then
1163  * the log meesage is considered complete.
1164  */
1165 OSAPIDllExport void
1166 OSAPI_Log_entry_create(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1167  const char *const module, const char *const file,
1168  const char *const func, RTI_INT32 line,RTI_BOOL is_final);
1169 
1170 /*ci
1171  * \brief Add an integer to a log-entry
1172  *
1173  * \ingroup OSAPILogClass
1174  *
1175  * \param[in] name The name of the integer being logged
1176  * \param[in] value The value of the integer being logged
1177  * \param[in] is_final RTI_TRUE if this is the last value added to the log entry
1178  * RTI_FALSE if more values are being added to the log entry
1179  */
1180 OSAPIDllExport void
1181 OSAPI_Log_entry_add_int(const char *name,RTI_INT32 value,RTI_BOOL is_final);
1182 
1183 /*ci
1184  * \brief Add a string to a log-entry
1185  *
1186  * \ingroup OSAPILogClass
1187  *
1188  * \param[in] name The name of the string being logged
1189  * \param[in] value The value of the string being logged
1190  * \param[in] is_final RTI_TRUE if this is the last value added to the log entry
1191  * RTI_FALSE if more values are being added to the log entry
1192  */
1193 OSAPIDllExport void
1194 OSAPI_Log_entry_add_string(const char *name,const char *value,RTI_BOOL is_final);
1195 
1196 
1197 /*ci
1198  * \brief Add a pointer to a log-entry
1199  *
1200  * \ingroup OSAPILogClass
1201  *
1202  * \param[in] name The name of the pointer being logged
1203  * \param[in] value The value of the pointer being logged
1204  * \param[in] is_final RTI_TRUE if this is the last value added to the log entry
1205  * RTI_FALSE if more values are being added to the log entry
1206  */
1207 OSAPIDllExport void
1208 OSAPI_Log_entry_add_pointer(const char *name,const void *value,RTI_BOOL is_final);
1209 
1210 OSAPIDllExport RTI_BOOL
1211 OSAPI_Log_entry_get_data(OSAPI_LogEntry_T *log_entry,char **data_ptr,
1212  OSAPI_LogType_T *type,const char **name,
1213  const void **value,RTI_BOOL *is_final);
1214 
1215 /*ci
1216  * \brief Create a new log-entry for an error-code with no additional data
1217  *
1218  * \ingroup OSAPILogClass
1219  *
1220  * \param[in] kind The type of log entry
1221  * \param[in] error_code The error-code
1222  * \param[in] module The name of the module logging the error
1223  * \param[in] file The file logging the error
1224  * \param[in] line The line number in file the error is logged
1225  *
1226  * \sa OSAPI_Log_entry_create
1227  */
1228 OSAPIDllExport void
1229 OSAPI_Log_entry_add(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1230  const char *const module, const char *const file,
1231  const char *const func, RTI_INT32 line);
1232 
1233 /*ci
1234  * \brief Create a new log-entry with a single integer
1235  *
1236  * \ingroup OSAPILogClass
1237  *
1238  * \param[in] kind The type of log entry
1239  * \param[in] error_code The error-code
1240  * \param[in] module The name of the module logging the error
1241  * \param[in] file The file logging the error
1242  * \param[in] line The line number in file the error is logged
1243  * \param[in] name The name of the integer being logged
1244  * \param[in] value The value of the integer being logged
1245  *
1246  */
1247 OSAPIDllExport void
1248 OSAPI_Log_entry_add_1int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1249  const char *const module, const char *const file,
1250  const char *const func, RTI_INT32 line,const char *name,
1251  RTI_INT32 value);
1252 
1253 
1254 /*ci
1255  * \brief Create a new log-entry with a 2 integers
1256  *
1257  * \ingroup OSAPILogClass
1258  *
1259  * \param[in] kind The type of log entry
1260  * \param[in] error_code The error-code
1261  * \param[in] module The name of the module logging the error
1262  * \param[in] file The file logging the error
1263  * \param[in] line The line number in file the error is logged
1264  * \param[in] name1 The name of the 1st integer being logged
1265  * \param[in] value1 The value of the 1st integer being logged
1266  * \param[in] name2 The name of the 2nd integer being logged
1267  * \param[in] value2 The value of the 2nd integer being logged
1268  *
1269  */
1270 OSAPIDllExport void
1271 OSAPI_Log_entry_add_2int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1272  const char *const module, const char *const file,
1273  const char *const func, RTI_INT32 line,
1274  const char *name1,RTI_INT32 value1,
1275  const char *name2,RTI_INT32 value2);
1276 
1277 /*ci
1278  * \brief Create a new log-entry with a 3 integers
1279  *
1280  * \ingroup OSAPILogClass
1281  *
1282  * \param[in] kind The type of log entry
1283  * \param[in] error_code The error-code
1284  * \param[in] module The name of the module logging the error
1285  * \param[in] file The file logging the error
1286  * \param[in] line The line number in file the error is logged
1287  * \param[in] name1 The name of the 1st integer being logged
1288  * \param[in] value1 The value of the 1st integer being logged
1289  * \param[in] name2 The name of the 2nd integer being logged
1290  * \param[in] value2 The value of the 2nd integer being logged
1291  * \param[in] name3 The name of the 3rd integer being logged
1292  * \param[in] value3 The value of the 3rd integer being logged
1293  *
1294  */
1295 OSAPIDllExport void
1296 OSAPI_Log_entry_add_3int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1297  const char *const module, const char *const file,
1298  const char *const func, RTI_INT32 line,
1299  const char *name1,RTI_INT32 value1,
1300  const char *name2,RTI_INT32 value2,
1301  const char *name3,RTI_INT32 value3);
1302 
1303 /*ci
1304  * \brief Create a new log-entry with a single string
1305  *
1306  * \ingroup OSAPILogClass
1307  *
1308  * \param[in] kind The type of log entry
1309  * \param[in] error_code The error-code
1310  * \param[in] module The name of the module logging the error
1311  * \param[in] file The file logging the error
1312  * \param[in] line The line number in file the error is logged
1313  * \param[in] name The name of the string being logged
1314  * \param[in] value The value of the string being logged
1315  *
1316  */
1317 OSAPIDllExport void
1318 OSAPI_Log_entry_add_1string(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1319  const char *const module, const char *const file,
1320  const char *const func, RTI_INT32 line,
1321  const char *name,const char* value);
1322 
1323 /*ci
1324  * \brief Create a new log-entry with a 2 strings
1325  *
1326  * \ingroup OSAPILogClass
1327  *
1328  * \param[in] kind The type of log entry
1329  * \param[in] error_code The error-code
1330  * \param[in] module The name of the module logging the error
1331  * \param[in] file The file logging the error
1332  * \param[in] line The line number in file the error is logged
1333  * \param[in] name1 The name of the 1st string being logged
1334  * \param[in] value1 The value of the 1st string being logged
1335  * \param[in] name2 The name of the 2nd string being logged
1336  * \param[in] value2 The value of the 2nd string being logged
1337  *
1338  */
1339 OSAPIDllExport void
1340 OSAPI_Log_entry_add_2string(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1341  const char *const module, const char *const file,
1342  const char *const func, RTI_INT32 line,
1343  const char *name1,const char* value1,
1344  const char *name2,const char* value2);
1345 
1346 /*ci
1347  * \brief Create a new log-entry with a single pointer
1348  *
1349  * \ingroup OSAPILogClass
1350  *
1351  * \param[in] kind The type of log entry
1352  * \param[in] error_code The error-code
1353  * \param[in] module The name of the module logging the error
1354  * \param[in] file The file logging the error
1355  * \param[in] line The line number in file the error is logged
1356  * \param[in] name The name of the pointer being logged
1357  * \param[in] value The value of the pointer being logged
1358  *
1359  */
1360 OSAPIDllExport void
1361 OSAPI_Log_entry_add_1pointer(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1362  const char *const module, const char *const file,
1363  const char *const func, RTI_INT32 line,
1364  const char *name, const void* value);
1365 
1366 /*ci
1367  * \brief Create a new log-entry with a single string and a integer
1368  *
1369  * \ingroup OSAPILogClass
1370  *
1371  * \param[in] kind The type of log entry
1372  * \param[in] error_code The error-code
1373  * \param[in] module The name of the module logging the error
1374  * \param[in] file The file logging the error
1375  * \param[in] line The line number in file the error is logged
1376  * \param[in] s_name The name of the string being logged
1377  * \param[in] s_value The value of the string being logged
1378  * \param[in] i_name The name of the integer being logged
1379  * \param[in] i_value The value of the string being logged
1380  */
1381 OSAPIDllExport void
1382 OSAPI_Log_entry_add_1string_1int(OSAPI_LogKind_T kind, RTI_INT32 error_code,
1383  const char *const module, const char *const file,
1384  const char *const func, RTI_INT32 line,
1385  const char *s_name,const char* s_value,
1386  const char *i_name,RTI_INT32 i_value);
1387 #endif /* OSAPI_ENABLE_LOG */
1388 
1389 /*ci
1390  * \brief Convert an integer to a string in decimal format
1391  * *
1392  * \param[inout] buffer Buffer to store result in
1393  * \param[in] max_length Maximum length of the buffer
1394  * \param[in] d The digit to convert
1395  *
1396  * \return The number of characters placed in the buffer excluding the
1397  * NULL termination. If there is insufficient space max_length
1398  * is returned.
1399  */
1400 OSAPIDllExport RTI_INT32
1401 OSAPI_Log_itoa(char *buffer,RTI_INT32 max_length,RTI_INT32 d);
1402 
1403 #ifdef __cplusplus
1404 } /* extern "C" */
1405 #endif
1406 
1407 #include "osapi/osapi_log_impl.h"
1408 
1409 #endif /* osapi_log_h */

RTI Connext DDS Micro Version 2.4.8 Copyright © Tue Apr 12 2016 Real-Time Innovations, Inc