oboe-heroku 0.8.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,609 @@
1
+ #ifndef LIBOBOE_H
2
+ #define LIBOBOE_H
3
+
4
+
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+
9
+ #include <stdio.h>
10
+ #include <sys/types.h>
11
+ #include <inttypes.h>
12
+ #include "bson/bson.h"
13
+ #include "oboe_debug.h"
14
+
15
+ /** Compile time debug logging detail level - cannot log more detailed than this. */
16
+ #define OBOE_DEBUG_LEVEL OBOE_DEBUG_HIGH
17
+
18
+ /**
19
+ * Default configuration settings update interval in seconds.
20
+ *
21
+ * Borrowed from the Tracelyzer's oboe.h.
22
+ */
23
+ #define OBOE_DEFAULT_SETTINGS_INTERVAL 30
24
+
25
+ /**
26
+ * Default heartbeat status update interval in seconds.
27
+ */
28
+ #define OBOE_DEFAULT_HEARTBEAT_INTERVAL 60
29
+
30
+ /**
31
+ * Default keepalive interval in seconds.
32
+ *
33
+ * A keepalive message will be sent after communications are idle for this interval.
34
+ */
35
+ #define OBOE_DEFAULT_KEEPALIVE_INTERVAL 20
36
+
37
+ #define OBOE_SAMPLE_RATE_DEFAULT 300000 // 30%
38
+ #define OBOE_SAMPLE_RESOLUTION 1000000
39
+
40
+ #define OBOE_MAX_TASK_ID_LEN 20
41
+ #define OBOE_MAX_OP_ID_LEN 8
42
+ #define OBOE_MAX_METADATA_PACK_LEN 512
43
+
44
+ #define XTR_CURRENT_VERSION 1
45
+ #define XTR_UDP_PORT 7831
46
+
47
+ #define OBOE_REPORTER_PROTOCOL_FILE "file"
48
+ #define OBOE_REPORTER_PROTOCOL_UDP "udp"
49
+ #define OBOE_REPORTER_PROTOCOL_SSL "ssl"
50
+
51
+ // structs
52
+
53
+ typedef struct oboe_ids {
54
+ uint8_t task_id[OBOE_MAX_TASK_ID_LEN];
55
+ uint8_t op_id[OBOE_MAX_OP_ID_LEN];
56
+ } oboe_ids_t;
57
+
58
+ typedef struct oboe_metadata {
59
+ oboe_ids_t ids;
60
+ size_t task_len;
61
+ size_t op_len;
62
+ } oboe_metadata_t;
63
+
64
+ typedef struct oboe_event {
65
+ oboe_metadata_t metadata;
66
+ bson_buffer bbuf;
67
+ char * bb_str;
68
+ } oboe_event_t;
69
+
70
+
71
+ // oboe_metadata
72
+
73
+ int oboe_metadata_init (oboe_metadata_t *);
74
+ int oboe_metadata_destroy (oboe_metadata_t *);
75
+
76
+ int oboe_metadata_is_valid (const oboe_metadata_t *);
77
+
78
+ void oboe_metadata_copy (oboe_metadata_t *, const oboe_metadata_t *);
79
+
80
+ void oboe_metadata_random (oboe_metadata_t *);
81
+
82
+ int oboe_metadata_set_lengths (oboe_metadata_t *, size_t, size_t);
83
+ int oboe_metadata_create_event (const oboe_metadata_t *, oboe_event_t *);
84
+
85
+ int oboe_metadata_tostr (const oboe_metadata_t *, char *, size_t);
86
+ int oboe_metadata_fromstr (oboe_metadata_t *, const char *, size_t);
87
+
88
+
89
+ // oboe_event
90
+
91
+ int oboe_event_init (oboe_event_t *, const oboe_metadata_t *);
92
+ int oboe_event_destroy (oboe_event_t *);
93
+
94
+ int oboe_event_add_info (oboe_event_t *, const char *, const char *);
95
+ int oboe_event_add_info_binary (oboe_event_t *, const char *, const char *, size_t);
96
+ int oboe_event_add_info_int64 (oboe_event_t *, const char *, const int64_t);
97
+ int oboe_event_add_info_double (oboe_event_t *, const char *, const double);
98
+ int oboe_event_add_info_bool (oboe_event_t *, const char *, const int);
99
+ int oboe_event_add_info_fmt (oboe_event_t *, const char *key, const char *fmt, ...);
100
+ int oboe_event_add_info_bson (oboe_event_t *, const char *key, const bson *val);
101
+ int oboe_event_add_edge (oboe_event_t *, const oboe_metadata_t *);
102
+ int oboe_event_add_edge_fromstr(oboe_event_t *, const char *, size_t);
103
+
104
+ /**
105
+ * Send event message using the default reporter.
106
+ *
107
+ * @param evt The event message.
108
+ * @param md The X-Trace metadata.
109
+ * @return Length of message sent in bytes on success; otherwise -1.
110
+ */
111
+ int oboe_event_send(oboe_event_t *evt, oboe_metadata_t *md);
112
+
113
+
114
+ // oboe_context
115
+
116
+ oboe_metadata_t *oboe_context_get();
117
+ void oboe_context_set(oboe_metadata_t *);
118
+ int oboe_context_set_fromstr(const char *, size_t);
119
+
120
+ void oboe_context_clear();
121
+
122
+ int oboe_context_is_valid();
123
+
124
+
125
+ // oboe_reporter
126
+
127
+ struct oboe_reporter;
128
+ typedef ssize_t (*reporter_send)(void *, const char *, size_t);
129
+ typedef int (*reporter_destroy)(void *);
130
+
131
+ typedef struct oboe_reporter {
132
+ void * descriptor; /*!< Reporter's context. */
133
+ // const char * protocol; /*!< Copy of the protocol string. */
134
+ // const char * args; /*!< Copy of the initialization arguement string. */
135
+ reporter_send send; /*!< Send a trace event message. */
136
+ reporter_destroy destroy; /*!< Destroy the reporter - release all resources. */
137
+ // reporter_ready ready; /*!< Check if the reporter is ready for another trace. Used by oboe_sample_request(). */
138
+ // reporter_disconnect disconnect; /*!< Disconnect reporter's connections. */
139
+ // reporter_reconnect reconnect; /*!< Restart/re-initialize reporter's connections. */
140
+ } oboe_reporter_t;
141
+
142
+ int oboe_reporter_udp_init (oboe_reporter_t *, const char *, const char *);
143
+ int oboe_reporter_udp_init_str(oboe_reporter_t *, const char *);
144
+ int oboe_reporter_file_init (oboe_reporter_t *, const char *);
145
+ int oboe_reporter_file_init_str(oboe_reporter_t *, const char *);
146
+ int oboe_reporter_ssl_init (oboe_reporter_t *, const char *);
147
+
148
+ /**
149
+ * Initialize a reporter structure for use with the specified protocol.
150
+ *
151
+ * @param rep Pointer to an uninitialized reporter structure.
152
+ * @param protocol One of OBOE_REPORTER_PROTOCOL_FILE, OBOE_REPORTER_PROTOCOL_UDP,
153
+ * or OBOE_REPORTER_PROTOCOL_SSL.
154
+ * @param args A configuration string for the specified protocol (protocol dependent syntax).
155
+ * @return Zero on success; otherwise -1.
156
+ */
157
+ int oboe_reporter_init (oboe_reporter_t *rep, const char *protocol, const char *args);
158
+
159
+ /**
160
+ * Check if the reporter is ready to send.
161
+ *
162
+ * The concept of 'ready' is depends on the specific reporter being used.
163
+ *
164
+ * @param rep The reporter context (optional).
165
+ * @return Non-zero if the reporter is ready to send.
166
+ */
167
+ int oboe_reporter_is_ready(oboe_reporter_t *rep);
168
+
169
+ /**
170
+ * Send an event message using the selected reporter context.
171
+ *
172
+ * @param rep The reporter context.
173
+ * @param evt The event message.
174
+ * @param md The X-Trace metadata.
175
+ * @return Length of message sent in bytes on success; otherwise -1.
176
+ */
177
+ int oboe_reporter_send(oboe_reporter_t *rep, oboe_metadata_t *md, oboe_event_t *evt);
178
+
179
+ /**
180
+ * Release any resources held by the reporter context.
181
+ *
182
+ * @param rep Pointer to a reporter context structure.
183
+ * @return Zero on success; otherwise non-zero to indicate an error.
184
+ */
185
+ int oboe_reporter_destroy(oboe_reporter_t *rep);
186
+
187
+ /**
188
+ * Disconnect or shut down the Oboe reporter, but allow it to be reconnect()ed.
189
+ *
190
+ * @param rep Pointer to the active reporter object.
191
+ */
192
+ void oboe_disconnect(oboe_reporter_t *rep);
193
+
194
+ /**
195
+ * Reconnect or restart the Oboe reporter.
196
+ *
197
+ * @param rep Pointer to the active reporter object.
198
+ */
199
+ void oboe_reconnect(oboe_reporter_t *rep);
200
+
201
+ /* Deprecated? Use oboe_reporter_send() */
202
+ ssize_t oboe_reporter_udp_send(void *desc, const char *data, size_t len);
203
+
204
+
205
+ // initialization
206
+
207
+ /**
208
+ * Initialize the Oboe subsystems.
209
+ *
210
+ * This should be called before any other oboe_* functions. However, in order
211
+ * to make the library easier to work with, checks are in place so that it
212
+ * will be called by any of the other functions that depend on it.
213
+ *
214
+ * Note that while calling this will be handled automatically, the application
215
+ * must still initialize one of the reporters directly since each reporter
216
+ * requires unique parameters. The use of oboe_reporter_init() is recommended
217
+ * so that the selection of the reporter and values for its configuration
218
+ * parameters
219
+ */
220
+ void oboe_init();
221
+
222
+ /**
223
+ * Shut down the Oboe subsystems.
224
+ *
225
+ * This may be called on exit in order to release any resources held by
226
+ * the Oboe library including any child threads.
227
+ */
228
+ void oboe_shutdown();
229
+
230
+
231
+ // Settings interface
232
+
233
+ #define OBOE_SETTINGS_VERSION 1
234
+ #define OBOE_SETTINGS_MAGIC_NUMBER 0x6f626f65
235
+ #define OBOE_SETTINGS_TYPE_SKIP 0
236
+ #define OBOE_SETTINGS_TYPE_STOP 1
237
+ #define OBOE_SETTINGS_TYPE_DEFAULT_SAMPLE_RATE 2
238
+ #define OBOE_SETTINGS_TYPE_LAYER_SAMPLE_RATE 3
239
+ #define OBOE_SETTINGS_TYPE_LAYER_APP_SAMPLE_RATE 4
240
+ #define OBOE_SETTINGS_TYPE_LAYER_HTTPHOST_SAMPLE_RATE 5
241
+ #define OBOE_SETTINGS_TYPE_CONFIG_STRING 6
242
+ #define OBOE_SETTINGS_TYPE_CONFIG_INT 7
243
+ #define OBOE_SETTINGS_FLAG_OK 0x0
244
+ #define OBOE_SETTINGS_FLAG_INVALID 0x1
245
+ #define OBOE_SETTINGS_FLAG_OVERRIDE 0x2
246
+ #define OBOE_SETTINGS_FLAG_SAMPLE_START 0x4
247
+ #define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH 0x8
248
+ #define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH_ALWAYS 0x10
249
+ #define OBOE_SETTINGS_FLAG_SAMPLE_AVW_ALWAYS 0x20
250
+ #define OBOE_SETTINGS_MAX_STRLEN 256
251
+
252
+ #define OBOE_SETTINGS_UNSET -1
253
+ #define OBOE_SETTINGS_MIN_REFRESH_INTERVAL 30
254
+
255
+ // Value for "SampleSource" info key
256
+ // where was the sample rate specified? (oboe settings, config file, hard-coded default, etc)
257
+ #define OBOE_SAMPLE_RATE_SOURCE_FILE 1
258
+ #define OBOE_SAMPLE_RATE_SOURCE_DEFAULT 2
259
+ #define OBOE_SAMPLE_RATE_SOURCE_OBOE 3
260
+ #define OBOE_SAMPLE_RATE_SOURCE_LAST_OBOE 4
261
+ #define OBOE_SAMPLE_RATE_SOURCE_DEFAULT_MISCONFIGURED 5
262
+ #define OBOE_SAMPLE_RATE_SOURCE_OBOE_DEFAULT 6
263
+
264
+ #define OBOE_SAMPLE_RESOLUTION 1000000
265
+
266
+ // Used to convert to settings flags:
267
+ #define OBOE_TRACE_NEVER 0
268
+ #define OBOE_TRACE_ALWAYS 1
269
+ #define OBOE_TRACE_THROUGH 2
270
+
271
+ typedef struct {
272
+ volatile uint32_t magic;
273
+ volatile uint32_t timestamp;
274
+ volatile uint16_t type;
275
+ volatile uint16_t flags;
276
+ volatile uint32_t value;
277
+ uint32_t _pad;
278
+ char layer[OBOE_SETTINGS_MAX_STRLEN];
279
+ char arg[OBOE_SETTINGS_MAX_STRLEN];
280
+ } __attribute__((packed)) oboe_settings_t;
281
+
282
+ // Current settings configuration:
283
+ typedef struct {
284
+ int tracing_mode; // loaded from config file
285
+ int sample_rate; // loaded from config file
286
+ int default_sample_rate; // default sample rate (fallback)
287
+ // oboe_reporter_t *reporter; // the initialized event reporter
288
+ oboe_settings_t *settings; // cached settings, updated by tracelyzer (init to NULL)
289
+ int last_auto_sample_rate; // stores last known automatic sampling rate
290
+ uint16_t last_auto_flags; // stores last known flags associated with above
291
+ uint32_t last_auto_timestamp; // timestamp from last *settings lookup
292
+ uint32_t last_refresh; // last refresh time
293
+ } oboe_settings_cfg_t;
294
+
295
+ int oboe_settings_init_local();
296
+ oboe_settings_t* oboe_settings_get(uint16_t type, const char* layer, const char* arg);
297
+ oboe_settings_t* oboe_settings_get_layer_tracing_mode(const char* layer);
298
+ oboe_settings_t* oboe_settings_get_layer_sample_rate(const char* layer);
299
+ oboe_settings_t* oboe_settings_get_layer_app_sample_rate(const char* layer, const char* app);
300
+ uint32_t oboe_settings_get_latest_timestamp(const char* layer);
301
+ int oboe_settings_get_value(oboe_settings_t *s, int *outval, unsigned short *outflags, uint32_t *outtimestamp);
302
+
303
+ oboe_settings_cfg_t* oboe_settings_cfg_get();
304
+ void oboe_settings_cfg_init(oboe_settings_cfg_t *cfg);
305
+ void oboe_settings_cfg_tracing_mode_set(int new_mode);
306
+ void oboe_settings_cfg_sample_rate_set(int new_rate);
307
+
308
+ int oboe_rand_get_value();
309
+
310
+
311
+ /**
312
+ * Check if sampling is enabled.
313
+ *
314
+ * @param cfg Optional pointer to the settings configuration for the current
315
+ * thread, as an optimization to avoid retrieving it. May be NULL.
316
+ * @return Non-zero if sampling is now enabled.
317
+ */
318
+ int oboe_sample_is_enabled(oboe_settings_cfg_t *cfg);
319
+
320
+ /**
321
+ * Check if this request should be sampled (deprecated - use oboe_sample_layer() instead).
322
+ *
323
+ * @param layer Layer name as used in oboe_settings_t.layer (may be NULL to use default settings)
324
+ * @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
325
+ * @param cfg The settings configuration to use for this evaluation.
326
+ * @param sample_rate_out The sample rate used to check if this request should be sampled
327
+ * (output - may be zero if not used).
328
+ * @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
329
+ * should be sampled (output - may be zero if not used).
330
+ * @return Non-zero if the given layer should be sampled.
331
+ */
332
+ int oboe_sample_request(const char *layer, const char *in_xtrace, oboe_settings_cfg_t *cfg,
333
+ int *sample_rate_out, int *sample_source_out);
334
+
335
+ /**
336
+ * Check if this request should be sampled.
337
+ *
338
+ * Checks for sample rate flags and settings for the specified layer, considers any
339
+ * special features in the X-Trace and X-TV-Meta HTTP headers, and, if appropriate,
340
+ * rolls the virtual dice to decide if this request should be sampled.
341
+ *
342
+ * This replaces oboe_sample_request with a version that uses the settings
343
+ * configuration kept in thread-local storage and takes the X-TV-Meta HTTP
344
+ * header value in order to support AppView Web integration.
345
+ *
346
+ * @param layer Layer name as used in oboe_settings_t.layer (may be NULL to use default settings)
347
+ * @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
348
+ * @param tv_meta AppView Web ID from X-TV-Meta HTTP header or higher layer (NULL or empty string if not present).
349
+ * @param sample_rate_out The sample rate used to check if this request should be sampled
350
+ * (output - may be zero if not used).
351
+ * @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
352
+ * should be sampled (output - may be zero if not used).
353
+ * @return Non-zero if the given layer should be sampled.
354
+ */
355
+ int oboe_sample_layer(
356
+ const char *layer,
357
+ const char *xtrace,
358
+ const char *tv_meta,
359
+ int *sample_rate_out,
360
+ int *sample_source_out
361
+ );
362
+
363
+ /* Oboe configuration interface. */
364
+
365
+ /**
366
+ * Check if the Oboe library is compatible with a given version.revision.
367
+ *
368
+ * This will succeed if the library is at least as recent as specified and if no
369
+ * definitions have been removed since that revision.
370
+ *
371
+ * @param version The library's version number which increments every time the API changes.
372
+ * @param revision The revision of the current version of the library.
373
+ * @return Non-zero if the Oboe library is considered compatible with the specified revision.
374
+ */
375
+ extern int oboe_config_check_version(int version, int revision);
376
+
377
+ /**
378
+ * Get the Oboe library version number.
379
+ *
380
+ * This number increments whenever the API is changed.
381
+ *
382
+ * @return The library's version number or -1 if the version is not known.
383
+ */
384
+ extern int oboe_config_get_version();
385
+
386
+ /**
387
+ <<<<<<< HEAD
388
+ * Prototype for a logger call-back function.
389
+ *
390
+ * A logging function of this form can be added to the logger chain using
391
+ * oboe_debug_log_add().
392
+ *
393
+ * @param context The context pointer that was registered in the call to
394
+ * oboe_debug_log_add(). Use it to pass the pointer-to-self for
395
+ * objects (ie. "this" in C++) or just a structure in C, May be
396
+ * NULL.
397
+ * @param module The module identifier as passed to oboe_debug_logger().
398
+ * @param level The diagnostic detail level as passed to oboe_debug_logger().
399
+ * @param source_name Name of the source file as passed to oboe_debug_logger().
400
+ * @param source_lineno Number of the line in the source file where message is
401
+ * logged from as passed to oboe_debug_logger().
402
+ * @param msg The formatted message produced from the format string and its
403
+ * arguments as passed to oboe_debug_logger().
404
+ */
405
+ typedef void (*OboeDebugLoggerFcn)(void *context, int module, int level, const char *source_name, int source_lineno, const char *msg);
406
+
407
+ /**
408
+ * Get a printable name for a diagnostics logging level.
409
+ */
410
+ extern const char *oboe_debug_log_level_name(int level);
411
+
412
+ /**
413
+ * Get a printable name for a diagnostics logging module identifier.
414
+ */
415
+ extern const char *oboe_debug_module_name(int module);
416
+
417
+ /**
418
+ * Get the maximum logging detail level for a module or for all modules.
419
+ *
420
+ * This level applies to the stderr logger only. Added loggers get all messages
421
+ * below their registed detail level and need to do their own module-specific
422
+ * filtering.
423
+ *
424
+ * @param module One of the OBOE_MODULE_* values. Use OBOE_MODULE_ALL (-1) to
425
+ * get the overall maximum detail level.
426
+ * @return Maximum detail level value for module (or overall) where zero is the
427
+ * lowest and higher values generate more detailed log messages.
428
+ */
429
+ extern int oboe_debug_log_level_get(int module);
430
+
431
+ /**
432
+ * Set the maximum logging detail level for a module or for all modules.
433
+ *
434
+ * This level applies to the stderr logger only. Added loggers get all messages
435
+ * below their registed detail level and need to do their own module-specific
436
+ * filtering.
437
+ *
438
+ * @param module One of the OBOE_MODULE_* values. Use OBOE_MODULE_ALL to set
439
+ * the overall maximum detail level.
440
+ * @param newLevel Maximum detail level value where zero is the lowest and higher
441
+ * values generate more detailed log messages.
442
+ */
443
+ extern void oboe_debug_log_level_set(int module, int newLevel);
444
+
445
+ /**
446
+ * Set the output stream for the default logger.
447
+ *
448
+ * @param newStream A valid, open FILE* stream or NULL to disable the default logger.
449
+ * @return Zero on success; otherwise an error code (normally from errno).
450
+ */
451
+ extern int oboe_debug_log_to_stream(FILE *newStream);
452
+
453
+ /**
454
+ * Set the default logger to write to the specified file.
455
+ *
456
+ * A NULL or empty path name will disable the default logger.
457
+ *
458
+ * If the file exists then it will be opened in append mode.
459
+ *
460
+ * @param pathname The path name of the
461
+ * @return Zero on success; otherwise an error code (normally from errno).
462
+ */
463
+ extern int oboe_debug_log_to_file(const char *pathname);
464
+
465
+ /**
466
+ * Add a logger that takes messages up to a given logging detail level.
467
+ *
468
+ * This adds the logger to a chain in order of the logging level. Log messages
469
+ * are passed to each logger down the chain until the remaining loggers only
470
+ * accept messages of a lower detail level.
471
+ *
472
+ * @return Zero on success, one if re-registered with the new logging level, and
473
+ * otherwise a negative value to indicate an error.
474
+ */
475
+ extern int oboe_debug_log_add(OboeDebugLoggerFcn newLogger, void *context, int logLevel);
476
+
477
+ /**
478
+ * Remove a logger.
479
+ *
480
+ * Remove the logger from the message handling chain.
481
+ *
482
+ * @return Zero on success, one if it was not found, and otherwise a negative
483
+ * value to indicate an error.
484
+ */
485
+ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
486
+
487
+ /**
488
+ * Log a fatal error.
489
+ */
490
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_FATAL
491
+ # define OBOE_DEBUG_LOG_FATAL(module, ...) \
492
+ { \
493
+ oboe_debug_logger(module, OBOE_DEBUG_FATAL, __FILE__, __LINE__, __VA_ARGS__); \
494
+ }
495
+ #else
496
+ # define OBOE_DEBUG_LOG_FATAL(module, format_string, ...) {}
497
+ #endif
498
+
499
+ /**
500
+ * Log a recoverable error.
501
+ */
502
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_ERROR
503
+ # define OBOE_DEBUG_LOG_ERROR(module, ...) \
504
+ { \
505
+ oboe_debug_logger(module, OBOE_DEBUG_ERROR, __FILE__, __LINE__, __VA_ARGS__); \
506
+ }
507
+ #else
508
+ # define OBOE_DEBUG_LOG_ERROR(module, format_string, ...) {}
509
+ #endif
510
+
511
+ /**
512
+ * Log a warning.
513
+ */
514
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_WARNING
515
+ # define OBOE_DEBUG_LOG_WARNING(module, ...) \
516
+ { \
517
+ oboe_debug_logger(module, OBOE_DEBUG_WARNING, __FILE__, __LINE__, __VA_ARGS__); \
518
+ }
519
+ #else
520
+ # define OBOE_DEBUG_LOG_WARNING(module, format_string,...) {}
521
+ #endif
522
+
523
+ /**
524
+ * Log an informative message.
525
+ */
526
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
527
+ # define OBOE_DEBUG_LOG_INFO(module, ...) \
528
+ { \
529
+ oboe_debug_logger(module, OBOE_DEBUG_INFO, __FILE__, __LINE__, __VA_ARGS__); \
530
+ }
531
+ #else
532
+ # define OBOE_DEBUG_LOG_INFO(module, format_string, ...) {}
533
+ #endif
534
+
535
+ /**
536
+ * Log a low-detail diagnostic message.
537
+ */
538
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_LOW
539
+ # define OBOE_DEBUG_LOG_LOW(module, ...) \
540
+ { \
541
+ oboe_debug_logger(module, OBOE_DEBUG_LOW, __FILE__, __LINE__, __VA_ARGS__); \
542
+ }
543
+ #else
544
+ # define OBOE_DEBUG_LOG_LOW(module, format_string, ...) {}
545
+ #endif
546
+
547
+ /**
548
+ * Log a medium-detail diagnostic message.
549
+ */
550
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_MEDIUM
551
+ # define OBOE_DEBUG_LOG_MEDIUM(module, ...) \
552
+ { \
553
+ oboe_debug_logger(module, OBOE_DEBUG_MEDIUM, __FILE__, __LINE__, __VA_ARGS__); \
554
+ }
555
+ #else
556
+ # define OBOE_DEBUG_LOG_MEDIUM(module, ...) {}
557
+ #endif
558
+
559
+ /**
560
+ * Log a high-detail diagnostic message.
561
+ */
562
+ #if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_HIGH
563
+ # define OBOE_DEBUG_LOG_HIGH(module, ...) \
564
+ { \
565
+ oboe_debug_logger(module, OBOE_DEBUG_HIGH, __FILE__, __LINE__, __VA_ARGS__); \
566
+ }
567
+ #else
568
+ # define OBOE_DEBUG_LOG_HIGH(module, format_string, ...) {}
569
+ #endif
570
+
571
+
572
+ /**
573
+ * Low-level diagnostics logging function.
574
+ *
575
+ * This is normally used only by the OBOE_DEBUG_LOG_* function macros and not used directly.
576
+ *
577
+ * This function may be adapted to format and route diagnostic log messages as desired.
578
+ *
579
+ * @param module One of the numeric module identifiers defined in debug.h - used to control logging detail by module.
580
+ * @param level Diagnostic detail level of this message - used to control logging volume by detail level.
581
+ * @param source_name Name of the source file, if available, or another useful name, or NULL.
582
+ * @param source_lineno Number of the line in the source file where message is logged from, if available, or zero.
583
+ * @param format A C language printf format specification string.
584
+ * @param args A variable argument list in VA_ARG format containing arguments for each argument specifier in the format.
585
+ */
586
+ void oboe_debug_logger(int module, int level, const char *source_name, int source_lineno, const char *format, ...);
587
+
588
+ /**
589
+ * Get the Oboe library revision number.
590
+ *
591
+ * This is the revision of the current version which is updated whenever
592
+ * compatible changes are made to the API/ABI (ie. additions).
593
+ *
594
+ * @return The library's revision number or -1 if not known.
595
+ */
596
+ extern int oboe_config_get_revision();
597
+
598
+ /*
599
+ * Get the Oboe library version as a string.
600
+ *
601
+ * Returns the complete VERSION string or null
602
+ */
603
+ const char* oboe_config_get_version_string();
604
+
605
+ #ifdef __cplusplus
606
+ } // extern "C"
607
+ #endif
608
+
609
+ #endif // LIBOBOE_H