3 * @author Martin Corino <mcorino@remedy.nl>
4 * * Macros used for logging in INet
8 #ifndef INET_LOG_MACROS_H_
9 #define INET_LOG_MACROS_H_
11 #include "ace/INet/INet_Export.h"
14 # define DLINFO ACE_TEXT("(%P|%t) [%M] - %T - ")
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
21 class ACE_INET_Export 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)
37 # define INET_NTRACE 1
39 # define INET_NTRACE 0
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)
49 # if (ACE_NTRACE == 0)
50 # error INET_TRACE cannot be disabled if ACE_TRACE is enabled
52 # define INET_TRACE(X) do {} while (0)
53 # define INET_ENABLE_TRACE() do {} while (0)
54 # define INET_DISABLE_TRACE() do {} while (0)
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; }
75 # if !defined (INET_ERROR)
76 # define INET_ERROR(L, X) \
78 if (::ACE::INet_Log::debug_level_ >= L) \
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); \
87 # if !defined (INET_DEBUG)
88 # define INET_DEBUG(L, X) \
90 if (::ACE::INet_Log::debug_level_ >= L) \
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); \
99 # if !defined (INET_HEX_DUMP)
100 #define INET_HEX_DUMP(L, X) \
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; \
111 # if !defined (INET_ERROR_RETURN)
112 # define INET_ERROR_RETURN(L, X, Y) \
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); \
124 # if !defined (INET_ERROR_BREAK)
125 # define INET_ERROR_BREAK(L, X) { INET_ERROR (L, X); break; }