#define BABELTRACE_LIB_LOGGING_INTERNAL_H
/*
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#include <babeltrace/babeltrace-internal.h>
#include <stdarg.h>
+#ifndef BT_LOG_TAG
+# error Please define a tag with BT_LOG_TAG before including this file.
+#endif
+
#define BT_LOG_OUTPUT_LEVEL bt_lib_log_level
#include <babeltrace/logging-internal.h>
extern
int bt_lib_log_level;
+#define BT_LIB_LOG(_lvl, _fmt, ...) \
+ do { \
+ if (BT_LOG_ON(_lvl)) { \
+ bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \
+ __LINE__, _lvl, _BT_LOG_TAG, \
+ (_fmt), ##__VA_ARGS__); \
+ } \
+ } while (0)
+
/*
* The six macros below are logging statements which are specialized
* for the Babeltrace library.
* `PRIi64`.
*
* The Babeltrace extension conversion specifier is accepted. Its syntax
- * is:
+ * is either `%!u` to format a UUID (`bt_uuid` type) or:
*
* 1. Introductory `%!` sequence.
*
* 3. Optional: `+` to print extended fields. This depends on the
* provided format specifier.
*
- * 4. Format specifier.
+ * 4. Format specifier (see below).
*
* The available format specifiers are:
*
- * `r`:
- * Reference count information. The parameter is any Babeltrace
- * object.
+ * `F`:
+ * Trace IR field class. The parameter type is
+ * `structbt_field_class *`.
+ *
+ * `f`:
+ * Trace IR field. The parameter type is `struct bt_field *`.
*
- * `F`:
- * Field type. The parameter type is `struct bt_field_type *`.
+ * `P`:
+ * Field path. The parameter type is `struct bt_field_path *`.
*
- * `f`:
- * Field. The parameter type is `struct bt_field *`.
+ * `E`:
+ * Trace IR event class. The parameter type is
+ * `struct bt_event_class *`.
*
- * `P`:
- * Field path. The parameter type is `struct bt_field_path *`.
+ * `e`:
+ * Trace IR event. The parameter type is `struct bt_event *`.
*
- * `E`:
- * Event class. The parameter type is `struct bt_event_class *`.
+ * `S`:
+ * Trace IR stream class. The parameter type is
+ * `struct bt_stream_class *`.
*
- * `e`:
- * Event. The parameter type is `struct bt_event *`.
+ * `s`:
+ * Trace IR stream. The parameter type is `struct bt_stream *`.
*
- * `S`:
- * Stream class. The parameter type is `struct bt_stream_class *`.
+ * `a`:
+ * Packet. The parameter type is `struct bt_packet *`.
*
- * `s`:
- * Stream. The parameter type is `struct bt_stream *`.
+ * `T`:
+ * Trace IR trace class. The parameter type is `struct bt_trace_class *`.
*
- * `a`:
- * Packet. The parameter type is `struct bt_packet *`.
+ * `t`:
+ * Trace IR trace. The parameter type is `struct bt_trace *`.
*
- * `t`:
- * Trace. The parameter type is `struct bt_trace *`.
+ * `K`:
+ * Clock class. The parameter type is `struct bt_clock_class *`.
*
- * `K`:
- * Clock class. The parameter type is `struct bt_clock_class *`.
+ * `k`:
+ * Clock snapshot. The parameter type is `struct bt_clock_snapshot *`.
*
- * `k`:
- * Clock value. The parameter type is `struct bt_clock_value *`.
+ * `v`:
+ * Value. The parameter type is `struct bt_value *`.
*
- * `v`:
- * Value. The parameter type is `struct bt_value *`.
+ * `n`:
+ * Message. The parameter type is `struct bt_message *`.
*
- * `n`:
- * Notification. The parameter type is `struct bt_notification *`.
+ * `i`:
+ * Message iterator. The parameter type is
+ * `struct bt_message_iterator *`.
*
- * `i`:
- * Notification iterator. The parameter type is
- * `struct bt_notification_iterator *`.
+ * `C`:
+ * Component class. The parameter type is `struct
+ * bt_component_class *`.
*
- * `C`:
- * Component class. The parameter type is `struct bt_component_class *`.
+ * `c`:
+ * Component. The parameter type is `struct bt_component *`.
*
- * `c`:
- * Component. The parameter type is `struct bt_component *`.
+ * `p`:
+ * Port. The parameter type is `struct bt_port *`.
*
- * `p`:
- * Port. The parameter type is `struct bt_port *`.
+ * `x`:
+ * Connection. The parameter type is `struct bt_connection *`.
*
- * `x`:
- * Connection. The parameter type is `struct bt_connection *`.
+ * `g`:
+ * Graph. The parameter type is `struct bt_graph *`.
*
- * `g`:
- * Graph. The parameter type is `struct bt_graph *`.
+ * `l`:
+ * Plugin. The parameter type is `const struct bt_plugin *`.
*
- * `u`:
- * Plugin. The parameter type is `struct bt_plugin *`.
+ * `o`:
+ * Object pool. The parameter type is `struct bt_object_pool *`.
*
- * `w`:
- * CTF writer. The parameter type is `struct bt_ctf_writer *`.
+ * `O`:
+ * Object. The parameter type is `struct bt_object *`.
+ *
+ * Conversion specifier examples:
+ *
+ * %!f
+ * %![my-event-]+e
+ * %!t
+ * %!+F
*
* The string `, ` is printed between individual fields, but not after
* the last one. Therefore you must put this separator in the format
* string between two Babeltrace objects, e.g.:
*
- * BT_LIB_LOGW("Message: count=%u, %!E, %!+C", count, event_class,
+ * BT_LIB_LOGW("Message: count=%u, %!E, %!+K", count, event_class,
* clock_class);
*
* Example with a custom prefix:
* It is safe to pass NULL as any Babeltrace object parameter: the
* macros only print its null address.
*/
-#define BT_LIB_LOG(_lvl, _fmt, ...) \
- do { \
- if (BT_LOG_ON(_lvl)) { \
- bt_lib_log(_BT_LOG_SRCLOC_FUNCTION, __FILE__, \
- __LINE__, _lvl, _BT_LOG_TAG, \
- (_fmt), ##__VA_ARGS__); \
- } \
- } while (0)
-
#define BT_LIB_LOGF(_fmt, ...) BT_LIB_LOG(BT_LOG_FATAL, _fmt, ##__VA_ARGS__)
#define BT_LIB_LOGE(_fmt, ...) BT_LIB_LOG(BT_LOG_ERROR, _fmt, ##__VA_ARGS__)
#define BT_LIB_LOGW(_fmt, ...) BT_LIB_LOG(BT_LOG_WARN, _fmt, ##__VA_ARGS__)