OpenDDS  Snapshot(2023/04/28-20:55)
debug.h
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #ifndef OPENDDS_DCPS_DEBUG_H
7 #define OPENDDS_DCPS_DEBUG_H
8 
9 #include "dcps_export.h"
10 
11 #ifndef OPENDDS_UTIL_BUILD
13 #endif
14 
15 #include <ace/ace_wchar.h>
16 
17 #ifndef ACE_LACKS_PRAGMA_ONCE
18 # pragma once
19 #endif
20 
22 
23 namespace OpenDDS {
24 namespace DCPS {
25 
26 /**
27  * General control for logging in OpenDDS.
28  *
29  * Access using the log_level global object.
30  */
32 public:
33  enum Value {
39  Debug
40  };
41 
43  {
44  set(value);
45  }
46 
47  void set(Value value);
48  void set_from_string(const char* name);
49 
50  Value get() const
51  {
52  return level_;
53  }
54  const char* get_as_string() const;
55 
56 private:
58 };
60 
61 inline bool operator>=(const LogLevel& ll, LogLevel::Value value)
62 {
63  return ll.get() >= value;
64 }
65 
66 /// Logging verbosity level.
67 /// set by Service_Participant
68 /// value guidelines:
69 /// 1 - logs that should happen once per process
70 /// 2 - logs that should happen once per DDS entity
71 /// 4 - logs that are related to administrative interfaces
72 /// 6 - logs that should happen every Nth sample write/read
73 /// 8 - logs that should happen once per sample write/read
74 /// 10 - logs that may happen more than once per sample write/read
75 extern OpenDDS_Dcps_Export unsigned int DCPS_debug_level;
76 
77 /// The proper way to set the DCPS_debug_level.
78 /// This function allows for possible side-effects of setting the level.
79 extern void OpenDDS_Dcps_Export set_DCPS_debug_level(unsigned int lvl);
80 
81 #ifndef OPENDDS_UTIL_BUILD
82 /// Transport Logging verbosity level.
83 // This needs to be initialized somewhere.
84 extern OpenDDS_Dcps_Export unsigned int Transport_debug_level;
86 #endif
87 
88 #ifdef OPENDDS_SECURITY
89 /**
90  * Global Security Debug Settings
91  */
93 public:
94  SecurityDebug();
95 
96  /// Set all security debug message flags to this value
97  void set_all_flags_to(bool value);
98 
99  /**
100  * Parse a comma delimited string and set the corresponding flags.
101  * Unknown ones are ignored and "all" enables all the flags.
102  * Ex: "bookkeeping,showkeys"
103  */
104  void parse_flags(const ACE_TCHAR* flags);
105 
106  /**
107  * Set debug level similarly to DCPSDebugLevel
108  */
109  void set_debug_level(unsigned level);
110 
111  /** @name SecurityFlags
112  * These are the categories of Security Debug Messages
113  */
114  ///@{
115  /// Encrypting and Decrypting
119 
120  /// Authentication and Handshake
122  bool auth_warn;
123 
124  /// New entity creating
127 
128  /// Cleanup
130 
131  /// Permissions and Governance
134 
135  /// Generation and Tracking of Crypto Handles and Keys
137 
138  /// Print the Key when Generating it or Using It
139  bool showkeys;
140 
141  /// Print Verbose Search Info About Getting the Crypto Handle from a Key id
142  bool chlookup;
143  ///@}
144 
145  /// Disable all encryption for security, even the required builtin encryption.
147 
148  /**
149  * Force role in authentication handshake. Like fake encryption this will
150  * break everything if applied inconsistently.
151  */
155  FORCE_AUTH_ROLE_FOLLOWER
156  } force_auth_role;
157 };
159 #endif
160 
161 #ifndef OPENDDS_UTIL_BUILD
162 class LogRestore {
163 public:
165  : orig_log_level_(log_level)
166  , orig_dcps_debug_level_(DCPS_debug_level)
167  , orig_transport_debug_level_(Transport_debug_level)
168  , orig_transport_debug_(transport_debug)
169 #ifdef OPENDDS_SECURITY
170  , orig_security_debug_(security_debug)
171 #endif
172  {
173  }
174 
176  {
177  log_level = orig_log_level_;
178  DCPS_debug_level = orig_dcps_debug_level_;
179  Transport_debug_level = orig_transport_debug_level_;
180  transport_debug = orig_transport_debug_;
181 #ifdef OPENDDS_SECURITY
182  security_debug = orig_security_debug_;
183 #endif
184  }
185 
186 private:
191 #ifdef OPENDDS_SECURITY
193 #endif
194 };
195 #endif // OPENDDS_UTIL_BUILD
196 
197 } // namespace DCPS
198 } // namespace OpenDDS
199 
201 
202 #endif /* OPENDDS_DCPS_DEBUG_H */
const LogLevel::Value value
Definition: debug.cpp:61
bool chlookup
Print Verbose Search Info About Getting the Crypto Handle from a Key id.
Definition: debug.h:142
OpenDDS_Dcps_Export TransportDebug transport_debug
Definition: debug.cpp:26
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
bool auth_debug
Authentication and Handshake.
Definition: debug.h:121
SecurityDebug orig_security_debug_
Definition: debug.h:192
bool cleanup_error
Cleanup.
Definition: debug.h:129
Value get() const
Definition: debug.h:50
bool access_error
Permissions and Governance.
Definition: debug.h:132
unsigned orig_dcps_debug_level_
Definition: debug.h:188
OpenDDS_Dcps_Export unsigned int Transport_debug_level
Transport Logging verbosity level.
Definition: debug.cpp:25
OpenDDS_Dcps_Export void set_DCPS_debug_level(unsigned int lvl)
Definition: debug.cpp:98
TransportDebug orig_transport_debug_
Definition: debug.h:190
char ACE_TCHAR
LogLevel(Value value)
Definition: debug.h:42
bool bookkeeping
Generation and Tracking of Crypto Handles and Keys.
Definition: debug.h:136
bool operator>=(const LogLevel &ll, LogLevel::Value value)
Definition: debug.h:61
const char *const name
Definition: debug.cpp:60
unsigned orig_transport_debug_level_
Definition: debug.h:189
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
OpenDDS_Dcps_Export LogLevel log_level
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
bool showkeys
Print the Key when Generating it or Using It.
Definition: debug.h:139
bool new_entity_error
New entity creating.
Definition: debug.h:125
LogLevel orig_log_level_
Definition: debug.h:187
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
bool fake_encryption
Disable all encryption for security, even the required builtin encryption.
Definition: debug.h:146
OpenDDS_Dcps_Export SecurityDebug security_debug
Definition: debug.cpp:32