solarwinds_apm 5.1.4 → 5.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,3 @@
1
- /**
2
- * @file: debug.h - Diagnostic logging functions for liboboe.
3
- *
4
- * Most of the diagnostics logging interface is defined in oboe.h but we
5
- * separate some of it out here for special handling when generating
6
- * SWIG interfaces.
7
- */
8
-
9
1
  #ifndef _OBOE_DEBUG_H
10
2
  #define _OBOE_DEBUG_H
11
3
 
@@ -13,6 +5,8 @@
13
5
  extern "C" {
14
6
  #endif
15
7
 
8
+ #include <stdbool.h>
9
+
16
10
  /**
17
11
  * Defined diagnostic log detail levels.
18
12
  */
@@ -44,14 +38,287 @@ enum OBOE_DEBUG_MODULE {
44
38
  OBOE_MODULE_PHP, /*!< PHP interpreter */
45
39
  OBOE_MODULE_DOTNET, /*!< dotnet wrapper */
46
40
  OBOE_MODULE_RUBY, /*!< ruby c++ extension */
41
+ OBOE_MODULE_HOST_ID_SERVICE,
42
+ OBOE_MODULE_AWS_RESOURCE_PROVIDER,
43
+ OBOE_MODULE_AZURE_RESOURCE_PROVIDER,
47
44
  };
48
45
 
46
+ /** Compile time debug logging detail level - cannot log more detailed than this. */
47
+ #define OBOE_DEBUG_LEVEL OBOE_DEBUG_HIGH
48
+
49
49
  /**
50
50
  * Initial debug log detail level.
51
51
  *
52
52
  */
53
53
  #define LOGLEVEL_DEFAULT OBOE_DEBUG_INFO
54
54
 
55
+ /** Limit for number of messages at specified level before demoting to debug MEDIUM. */
56
+ #define MAX_DEBUG_MSG_COUNT 1
57
+
58
+ void oboe_debug_log_init(FILE* output);
59
+
60
+ /**
61
+ * Low-level diagnostics logging function.
62
+ *
63
+ * This is normally used only by the OBOE_DEBUG_LOG_* function macros and not used directly.
64
+ *
65
+ * This function may be adapted to format and route diagnostic log messages as desired.
66
+ *
67
+ * @param module One of the numeric module identifiers defined in debug.h - used to control logging detail by module.
68
+ * @param level Diagnostic detail level of this message - used to control logging volume by detail level.
69
+ * @param source_name Name of the source file, if available, or another useful name, or NULL.
70
+ * @param source_lineno Number of the line in the source file where message is logged from, if available, or zero.
71
+ * @param format A C language printf format specification string.
72
+ * @param args A variable argument list in VA_ARG format containing arguments for each argument specifier in the format.
73
+ */
74
+ void oboe_debug_logger(int module, int level, const char *source_name, int source_lineno, const char *format, ...);
75
+
76
+
77
+ /**
78
+ * Prototype for a logger call-back function.
79
+ *
80
+ * A logging function of this form can be added to the logger chain using
81
+ * oboe_debug_log_add().
82
+ *
83
+ * @param context The context pointer that was registered in the call to
84
+ * oboe_debug_log_add(). Use it to pass the pointer-to-self for
85
+ * objects (ie. "this" in C++) or just a structure in C, May be
86
+ * NULL.
87
+ * @param module The module identifier as passed to oboe_debug_logger().
88
+ * @param level The diagnostic detail level as passed to oboe_debug_logger().
89
+ * @param source_name Name of the source file as passed to oboe_debug_logger().
90
+ * @param source_lineno Number of the line in the source file where message is
91
+ * logged from as passed to oboe_debug_logger().
92
+ * @param msg The formatted message produced from the format string and its
93
+ * arguments as passed to oboe_debug_logger().
94
+ */
95
+ typedef void (*OboeDebugLoggerFcn)(void *context, int module, int level, const char *source_name, int source_lineno, const char *msg);
96
+
97
+ /**
98
+ * Get a printable name for a diagnostics logging level.
99
+ */
100
+ const char *oboe_debug_log_level_name(int level);
101
+
102
+ /**
103
+ * Get a printable name for a diagnostics logging module identifier.
104
+ */
105
+ const char *oboe_debug_module_name(int module);
106
+
107
+ /**
108
+ * Get the maximum logging detail level for a module or for all modules.
109
+ *
110
+ * This level applies to the stderr logger only. Added loggers get all messages
111
+ * below their registed detail level and need to do their own module-specific
112
+ * filtering.
113
+ *
114
+ * @param module One of the OBOE_MODULE_* values. Use OBOE_MODULE_ALL (-1) to
115
+ * get the overall maximum detail level.
116
+ * @return Maximum detail level value for module (or overall) where zero is the
117
+ * lowest and higher values generate more detailed log messages.
118
+ */
119
+ int oboe_debug_log_level_get(int module);
120
+
121
+ /**
122
+ * Set the maximum logging detail level for a module or for all modules.
123
+ *
124
+ * This level applies to the stderr logger only. Added loggers get all messages
125
+ * below their registered detail level and need to do their own module-specific
126
+ * filtering.
127
+ *
128
+ * @param module One of the OBOE_MODULE_* values. Use OBOE_MODULE_ALL to set
129
+ * the overall maximum detail level.
130
+ * @param newLevel Maximum detail level value where zero is the lowest and higher
131
+ * values generate more detailed log messages.
132
+ */
133
+ void oboe_debug_log_level_set(FILE* output, int module, int newLevel);
134
+
135
+ /**
136
+ * Set the output stream for the default logger.
137
+ *
138
+ * @param newStream A valid, open FILE* stream or NULL to disable the default logger.
139
+ * @return Zero on success; otherwise an error code (normally from errno).
140
+ */
141
+ int oboe_debug_log_to_stream(FILE *newStream);
142
+
143
+ /**
144
+ * If we're logging to a stream, flush it.
145
+ *
146
+ * @return Zero on success; otherwise an error code (normally from errno).
147
+ */
148
+ int oboe_debug_log_flush();
149
+
150
+ /**
151
+ * Set the default logger to write to the specified file.
152
+ *
153
+ * A NULL or empty path name will disable the default logger.
154
+ *
155
+ * If the file exists then it will be opened in append mode.
156
+ *
157
+ * @param pathname The path name of the
158
+ * @return Zero on success; otherwise an error code (normally from errno).
159
+ */
160
+ int oboe_debug_log_to_file(const char *pathname);
161
+
162
+ /**
163
+ * Add a logger that takes messages up to a given logging detail level.
164
+ *
165
+ * This adds the logger to a chain in order of the logging level. Log messages
166
+ * are passed to each logger down the chain until the remaining loggers only
167
+ * accept messages of a lower detail level.
168
+ *
169
+ * @return Zero on success, one if re-registered with the new logging level, and
170
+ * otherwise a negative value to indicate an error.
171
+ */
172
+ int oboe_debug_log_add(OboeDebugLoggerFcn newLogger, void *context, int logLevel);
173
+
174
+ /**
175
+ * Remove a logger.
176
+ *
177
+ * Remove the logger from the message handling chain.
178
+ *
179
+ * @return Zero on success, one if it was not found, and otherwise a negative
180
+ * value to indicate an error.
181
+ */
182
+ int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
183
+
184
+ /*
185
+ * Log the application's Oboe configuration.
186
+ *
187
+ * We use this to get a reasonable standard format between apps.
188
+ *
189
+ * @param module An OBOE_MODULE_* module identifier. Use zero for undefined.
190
+ * @param app_name Either NULL or a pointer to a string containing a name for
191
+ * the application - will prefix the log entry. Useful when multiple
192
+ * apps log to the same destination.
193
+ * @param trace_mode A string identifying the configured tracing mode, one of:
194
+ * "enabled", "disabled", "unset", or "undef" (for invalid values)
195
+ * Use the oboe_tracing_mode_to_string() function to convert from
196
+ * numeric values.
197
+ * @param sample_rate The configured sampling rate: -1 for unset or a
198
+ * integer fraction of 1000000.
199
+ * @param reporter_type String identifying the type of reporter configured:
200
+ * One of 'udp' (the default), 'ssl', or 'file'.
201
+ * @param reporter_args The string of comma-separated key=value settings
202
+ * used to initialize the reporter.
203
+ * @param extra: Either NULL or a pointer to a string to be appended to
204
+ * the log message and designed to include a few other
205
+ * configuration parameters of interest.
206
+ */
207
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
208
+ # define OBOE_DEBUG_LOG_CONFIG_EX(module, app_name, trace_mode, sample_rate, reporter_type, reporter_args, extra) \
209
+ { \
210
+ oboe_debug_logger(module, OBOE_DEBUG_INFO, __FILE__, __LINE__, \
211
+ "%s Oboe config: tracing=%s, sampling=%d, reporter=('%s', '%s') %s", \
212
+ (app_name == NULL ? "" : app_name), \
213
+ trace_mode, \
214
+ sample_rate, \
215
+ (reporter_type == NULL ? "?" : reporter_type), \
216
+ (reporter_args == NULL ? "?" : reporter_args), \
217
+ (extra == NULL ? "" : extra)); \
218
+ }
219
+ #else
220
+ # define OBOE_DEBUG_LOG_CONFIG_EX(module, app_name, trace_mode, sample_rate, reporter_type, reporter_args, extra) {}
221
+ #endif
222
+
223
+ /**
224
+ * Log a fatal error.
225
+ */
226
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_FATAL
227
+ # define OBOE_DEBUG_LOG_FATAL_EX(module, ...) \
228
+ { \
229
+ oboe_debug_logger(module, OBOE_DEBUG_FATAL, __FILE__, __LINE__, __VA_ARGS__); \
230
+ }
231
+ #else
232
+ # define OBOE_DEBUG_LOG_FATAL_EX(module, ...) {}
233
+ #endif
234
+
235
+ /**
236
+ * Log a recoverable error.
237
+ *
238
+ * Each message is limited in the number of times that it will be reported at the
239
+ * ERROR level after which it will be logged at the debug MEDIUM level.
240
+ */
241
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_ERROR
242
+ # define OBOE_DEBUG_LOG_ERROR_EX(module, ...) \
243
+ { \
244
+ static int usage_counter = 0; \
245
+ int loglev = (++usage_counter <= MAX_DEBUG_MSG_COUNT ? OBOE_DEBUG_ERROR : OBOE_DEBUG_MEDIUM); \
246
+ oboe_debug_logger(module, loglev, __FILE__, __LINE__, __VA_ARGS__); \
247
+ }
248
+ #else
249
+ # define OBOE_DEBUG_LOG_ERROR_EX(module, ...) {}
250
+ #endif
251
+
252
+ /**
253
+ * Log a warning.
254
+ *
255
+ * Each message is limited in the number of times that it will be reported at the
256
+ * WARNING level after which it will be logged at the debug MEDIUM level.
257
+ */
258
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_WARNING
259
+ # define OBOE_DEBUG_LOG_WARNING_EX(module, ...) \
260
+ { \
261
+ static int usage_counter = 0; \
262
+ int loglev = (++usage_counter <= MAX_DEBUG_MSG_COUNT ? OBOE_DEBUG_WARNING : OBOE_DEBUG_MEDIUM); \
263
+ oboe_debug_logger(module, loglev, __FILE__, __LINE__, __VA_ARGS__); \
264
+ }
265
+ #else
266
+ # define OBOE_DEBUG_LOG_WARNING_EX(module, ...) {}
267
+ #endif
268
+
269
+ /**
270
+ * Log an informative message.
271
+ *
272
+ * Each message is limited in the number of times that it will be reported at the
273
+ * INFO level after which it will be logged at the debug MEDIUM level.
274
+ */
275
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
276
+ # define OBOE_DEBUG_LOG_INFO_EX(module, ...) \
277
+ { \
278
+ static int usage_counter = 0; \
279
+ int loglev = (++usage_counter <= MAX_DEBUG_MSG_COUNT ? OBOE_DEBUG_INFO : OBOE_DEBUG_MEDIUM); \
280
+ oboe_debug_logger(module, loglev, __FILE__, __LINE__, __VA_ARGS__); \
281
+ }
282
+ #else
283
+ # define OBOE_DEBUG_LOG_INFO_EX(module, ...) {}
284
+ #endif
285
+
286
+ /**
287
+ * Log a low-detail diagnostic message.
288
+ */
289
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_LOW
290
+ # define OBOE_DEBUG_LOG_LOW_EX(module, ...) \
291
+ { \
292
+ oboe_debug_logger(module, OBOE_DEBUG_LOW, __FILE__, __LINE__, __VA_ARGS__); \
293
+ }
294
+ #else
295
+ # define OBOE_DEBUG_LOG_LOW_EX(module, ...) {}
296
+ #endif
297
+
298
+ /**
299
+ * Log a medium-detail diagnostic message.
300
+ */
301
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_MEDIUM
302
+ # define OBOE_DEBUG_LOG_MEDIUM_EX(module, ...) \
303
+ { \
304
+ oboe_debug_logger(module, OBOE_DEBUG_MEDIUM, __FILE__, __LINE__, __VA_ARGS__); \
305
+ }
306
+ #else
307
+ # define OBOE_DEBUG_LOG_MEDIUM_EX(module, ...) {}
308
+ #endif
309
+
310
+ /**
311
+ * Log a high-detail diagnostic message.
312
+ */
313
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_HIGH
314
+ # define OBOE_DEBUG_LOG_HIGH_EX(module, ...) \
315
+ { \
316
+ oboe_debug_logger(module, OBOE_DEBUG_HIGH, __FILE__, __LINE__, __VA_ARGS__); \
317
+ }
318
+ #else
319
+ # define OBOE_DEBUG_LOG_HIGH_EX(module, ...) {}
320
+ #endif
321
+
55
322
  #ifdef __cplusplus
56
323
  } // extern "C"
57
324
  #endif