OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
trace.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, Rockwell Automation, Inc.
3  * All rights reserved.
4  *
5  ******************************************************************************/
6 #ifndef OPENER_TRACE_H_
7 #define OPENER_TRACE_H_
8 
9 #include <opener_user_conf.h>
10 
15 #ifdef OPENER_WITH_TRACES
16 
20 #define OPENER_TRACE_LEVEL_ERROR 0x01
21 
23 #define OPENER_TRACE_LEVEL_WARNING 0x02
24 
26 #define OPENER_TRACE_LEVEL_STATE 0x04
27 
29 #define OPENER_TRACE_LEVEL_INFO 0x08
30 
31 #ifndef OPENER_TRACE_LEVEL
32 #ifdef WIN32
33 #pragma message( \
34  "OPENER_TRACE_LEVEL was not defined setting it to OPENER_TRACE_LEVEL_ERROR")
35 #else
36 #warning \
37  OPENER_TRACE_LEVEL was not defined setting it to OPENER_TRACE_LEVEL_ERROR
38 #endif
39 
40 #define OPENER_TRACE_LEVEL OPENER_TRACE_LEVEL_ERROR
41 #endif
42 
43 /* @def OPENER_TRACE_ENABLED Can be used for conditional code compilation */
44 #define OPENER_TRACE_ENABLED
45 
50 #define OPENER_TRACE_ERR(...) \
51  do { \
52  if (OPENER_TRACE_LEVEL_ERROR & OPENER_TRACE_LEVEL) {LOG_TRACE(__VA_ARGS__);} \
53  } while (0)
54 
59 #define OPENER_TRACE_WARN(...) \
60  do { \
61  if (OPENER_TRACE_LEVEL_WARNING & OPENER_TRACE_LEVEL) { \
62  LOG_TRACE(__VA_ARGS__);} \
63  } while (0)
64 
69 #define OPENER_TRACE_STATE(...) \
70  do { \
71  if (OPENER_TRACE_LEVEL_STATE & OPENER_TRACE_LEVEL) {LOG_TRACE(__VA_ARGS__);} \
72  } while (0)
73 
78 #define OPENER_TRACE_INFO(...) \
79  do { \
80  if (OPENER_TRACE_LEVEL_INFO & OPENER_TRACE_LEVEL) {LOG_TRACE(__VA_ARGS__);} \
81  } while (0)
82 
83 #else
84 /* define the tracing macros empty in order to save space */
85 
86 #define OPENER_TRACE_ERR(...)
87 #define OPENER_TRACE_WARN(...)
88 #define OPENER_TRACE_STATE(...)
89 #define OPENER_TRACE_INFO(...)
90 #endif
91 /* TRACING *******************************************************************/
92 
93 #endif /*OPENER_TRACE_H_*/