Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / protocols / ace / INet / INet_Log.h
blobce5b18d5c227b943265dbff15bf6145c048d900e
1 /**
2 * @file INet_Log.h
3 * @author Martin Corino <mcorino@remedy.nl>
4 * * Macros used for logging in INet
5 */
8 #ifndef INET_LOG_MACROS_H_
9 #define INET_LOG_MACROS_H_
11 #include "ace/INet/INet_Export.h"
13 #if !defined (DLINFO)
14 # define DLINFO ACE_TEXT("(%P|%t) [%M] - %T - ")
15 #endif
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 namespace ACE
21 class ACE_INET_Export INet_Log
23 public:
24 INet_Log () {}
26 static unsigned int debug_level_;
28 static unsigned int Initializer ();
32 ACE_END_VERSIONED_NAMESPACE_DECL
34 // By default tracing is turned on in debugmode, off otherwise
35 #if !defined (INET_NTRACE)
36 # if defined (NDEBUG)
37 # define INET_NTRACE 1
38 # else
39 # define INET_NTRACE 0
40 # endif
41 #endif /* INET_NTRACE */
43 #if (INET_NTRACE == 1)
44 # if !defined (ACE_NTRACE)
45 # define INET_TRACE(X) do {} while (0)
46 # define INET_ENABLE_TRACE() do {} while (0)
47 # define INET_DISABLE_TRACE() do {} while (0)
48 # else
49 # if (ACE_NTRACE == 0)
50 # error INET_TRACE cannot be disabled if ACE_TRACE is enabled
51 # else
52 # define INET_TRACE(X) do {} while (0)
53 # define INET_ENABLE_TRACE() do {} while (0)
54 # define INET_DISABLE_TRACE() do {} while (0)
55 # endif
56 # endif
57 #else
58 # if !defined (ACE_HAS_TRACE)
59 # define ACE_HAS_TRACE
60 # endif /* ACE_HAS_TRACE */
61 # define INET_TRACE(X) ACE_TRACE_IMPL (X)
62 # define INET_ENABLE_TRACE() ACE_Trace::start_tracing ()
63 # define INET_DISABLE_TRACE() ACE_Trace::stop_tracing ()
64 # undef DLINFO // Make log messages indent with tracing.
65 # define DLINFO ACE_TEXT("%I(%P|%t) [%M] - %T - ")
66 # include "ace/Trace.h"
67 #endif /* INET_NTRACE */
69 #if defined (INET_NLOGGING)
70 # define INET_ERROR(L, X) do {} while (0)
71 # define INET_DEBUG(L, X) do {} while (0)
72 #define INET_ERROR_RETURN(L, X, Y) return (Y)
73 #define INET_ERROR_BREAK(L, X) { break; }
74 #else
75 # if !defined (INET_ERROR)
76 # define INET_ERROR(L, X) \
77 do { \
78 if (::ACE::INet_Log::debug_level_ >= L) \
79 { \
80 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
81 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
82 ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \
83 ace___->log X; \
84 } \
85 } while (0)
86 # endif
87 # if !defined (INET_DEBUG)
88 # define INET_DEBUG(L, X) \
89 do { \
90 if (::ACE::INet_Log::debug_level_ >= L) \
91 { \
92 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
93 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
94 ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \
95 ace___->log X; \
96 } \
97 } while (0)
98 # endif
99 # if !defined (INET_HEX_DUMP)
100 #define INET_HEX_DUMP(L, X) \
101 do { \
102 if (::ACE::INet_Log::debug_level_ >= L) \
104 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
105 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
106 ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \
107 ace___->log_hexdump X; \
109 } while (0)
110 #endif
111 # if !defined (INET_ERROR_RETURN)
112 # define INET_ERROR_RETURN(L, X, Y) \
113 do { \
114 if (::ACE::INet_Log::debug_level_ >= L) \
116 int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
117 ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
118 ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \
119 ace___->log X; \
120 return Y; \
122 } while (0)
123 # endif
124 # if !defined (INET_ERROR_BREAK)
125 # define INET_ERROR_BREAK(L, X) { INET_ERROR (L, X); break; }
126 # endif
127 #endif
130 #endif