The resulting lttng view output should look like this:
-[15:54:19.454863179] (+?.?????????) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 0" }
-[15:54:19.454871660] (+0.000008481) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 1" }
-[15:54:19.454872838] (+0.000001178) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 2" }
-[15:54:19.454873541] (+0.000000703) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 3" }
-[15:54:19.454874283] (+0.000000742) thinkos lttng_ust_tracelog:err: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 4" }
+[15:54:19.454863179] (+?.?????????) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 0" }
+[15:54:19.454871660] (+0.000008481) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 1" }
+[15:54:19.454872838] (+0.000001178) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 2" }
+[15:54:19.454873541] (+0.000000703) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 3" }
+[15:54:19.454874283] (+0.000000742) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 0 }, { line = 45, file = "demo-tracelog.c", func = "main", _msg_length = 17, msg = "Error condition 4" }
fprintf(stderr, "Tracing... ");
for (i = 0; i < 5; i++) {
- tracelog(err, "Error condition %d", i);
+ tracelog(TRACE_ERR, "Error condition %d", i);
}
fprintf(stderr, " done.\n");
return 0;
1) #include <lttng/tracelog.h>
2) /* in your code, use like a printf, with extra loglevel info. */
- tracelog(info, "Message with integer %d", 1234);
+ tracelog(TRACE_INFO, "Message with integer %d", 1234);
3) Link your program against liblttng-ust.so.
You can replace the enable-event line above with a selection of
loglevels, e.g.:
- lttng enable-event -u -a --loglevel INFO
+ lttng enable-event -u -a --loglevel TRACE_INFO
-Which will gather all events from INFO and more important loglevels.
+Which will gather all events from TRACE_INFO and more important
+loglevels.
.PP
#include <lttng/tracepoint.h>
#include <stdarg.h>
-#define TP_TRACELOG_TEMPLATE(_level_identifier, _level_enum) \
- TRACEPOINT_EVENT(lttng_ust_tracelog, _level_identifier, \
+#define TP_TRACELOG_TEMPLATE(_level_enum) \
+ TRACEPOINT_EVENT(lttng_ust_tracelog, _level_enum, \
TP_ARGS(const char *, file, int, line, const char *, func, \
const char *, msg, unsigned int, len, void *, ip), \
TP_FIELDS( \
ctf_sequence_text(char, msg, msg, unsigned int, len) \
) \
) \
- TRACEPOINT_LOGLEVEL(lttng_ust_tracelog, _level_identifier, \
- TRACE_##_level_enum)
+ TRACEPOINT_LOGLEVEL(lttng_ust_tracelog, _level_enum, _level_enum)
-TP_TRACELOG_TEMPLATE(emerg, EMERG)
-TP_TRACELOG_TEMPLATE(alert, ALERT)
-TP_TRACELOG_TEMPLATE(crit, CRIT)
-TP_TRACELOG_TEMPLATE(err, ERR)
-TP_TRACELOG_TEMPLATE(warning, WARNING)
-TP_TRACELOG_TEMPLATE(notice, NOTICE)
-TP_TRACELOG_TEMPLATE(info, INFO)
-TP_TRACELOG_TEMPLATE(debug_system, DEBUG_SYSTEM)
-TP_TRACELOG_TEMPLATE(debug_program, DEBUG_PROGRAM)
-TP_TRACELOG_TEMPLATE(debug_process, DEBUG_PROCESS)
-TP_TRACELOG_TEMPLATE(debug_module, DEBUG_MODULE)
-TP_TRACELOG_TEMPLATE(debug_unit, DEBUG_UNIT)
-TP_TRACELOG_TEMPLATE(debug_function, DEBUG_FUNCTION)
-TP_TRACELOG_TEMPLATE(debug_line, DEBUG_LINE)
-TP_TRACELOG_TEMPLATE(debug, DEBUG)
+TP_TRACELOG_TEMPLATE(TRACE_EMERG)
+TP_TRACELOG_TEMPLATE(TRACE_ALERT)
+TP_TRACELOG_TEMPLATE(TRACE_CRIT)
+TP_TRACELOG_TEMPLATE(TRACE_ERR)
+TP_TRACELOG_TEMPLATE(TRACE_WARNING)
+TP_TRACELOG_TEMPLATE(TRACE_NOTICE)
+TP_TRACELOG_TEMPLATE(TRACE_INFO)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG_SYSTEM)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG_PROGRAM)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG_PROCESS)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG_MODULE)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG_UNIT)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG_FUNCTION)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG_LINE)
+TP_TRACELOG_TEMPLATE(TRACE_DEBUG)
extern void _lttng_ust_tracelog_##level(const char *file, \
int line, const char *func, const char *fmt, ...)
-TP_TRACELOG_CB_TEMPLATE(emerg);
-TP_TRACELOG_CB_TEMPLATE(alert);
-TP_TRACELOG_CB_TEMPLATE(crit);
-TP_TRACELOG_CB_TEMPLATE(err);
-TP_TRACELOG_CB_TEMPLATE(warning);
-TP_TRACELOG_CB_TEMPLATE(notice);
-TP_TRACELOG_CB_TEMPLATE(info);
-TP_TRACELOG_CB_TEMPLATE(debug_system);
-TP_TRACELOG_CB_TEMPLATE(debug_program);
-TP_TRACELOG_CB_TEMPLATE(debug_process);
-TP_TRACELOG_CB_TEMPLATE(debug_module);
-TP_TRACELOG_CB_TEMPLATE(debug_unit);
-TP_TRACELOG_CB_TEMPLATE(debug_function);
-TP_TRACELOG_CB_TEMPLATE(debug_line);
-TP_TRACELOG_CB_TEMPLATE(debug);
+TP_TRACELOG_CB_TEMPLATE(TRACE_EMERG);
+TP_TRACELOG_CB_TEMPLATE(TRACE_ALERT);
+TP_TRACELOG_CB_TEMPLATE(TRACE_CRIT);
+TP_TRACELOG_CB_TEMPLATE(TRACE_ERR);
+TP_TRACELOG_CB_TEMPLATE(TRACE_WARNING);
+TP_TRACELOG_CB_TEMPLATE(TRACE_NOTICE);
+TP_TRACELOG_CB_TEMPLATE(TRACE_INFO);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG_SYSTEM);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG_PROGRAM);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG_PROCESS);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG_MODULE);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG_UNIT);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG_FUNCTION);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG_LINE);
+TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG);
#undef TP_TRACELOG_CB_TEMPLATE
#define tracelog(level, fmt, ...) \
do { \
STAP_PROBEV(tracepoint_lttng_ust_tracelog, level, ## __VA_ARGS__); \
- if (caa_unlikely(__tracepoint_lttng_ust_tracelog___## level.state)) \
+ if (caa_unlikely(__tracepoint_lttng_ust_tracelog___##level.state)) \
_lttng_ust_tracelog_##level(__FILE__, __LINE__, __func__, \
fmt, ## __VA_ARGS__); \
} while (0)
va_end(ap); \
}
-TRACELOG_CB(emerg)
-TRACELOG_CB(alert)
-TRACELOG_CB(crit)
-TRACELOG_CB(err)
-TRACELOG_CB(warning)
-TRACELOG_CB(notice)
-TRACELOG_CB(info)
-TRACELOG_CB(debug_system)
-TRACELOG_CB(debug_program)
-TRACELOG_CB(debug_process)
-TRACELOG_CB(debug_module)
-TRACELOG_CB(debug_unit)
-TRACELOG_CB(debug_function)
-TRACELOG_CB(debug_line)
-TRACELOG_CB(debug)
+TRACELOG_CB(TRACE_EMERG)
+TRACELOG_CB(TRACE_ALERT)
+TRACELOG_CB(TRACE_CRIT)
+TRACELOG_CB(TRACE_ERR)
+TRACELOG_CB(TRACE_WARNING)
+TRACELOG_CB(TRACE_NOTICE)
+TRACELOG_CB(TRACE_INFO)
+TRACELOG_CB(TRACE_DEBUG_SYSTEM)
+TRACELOG_CB(TRACE_DEBUG_PROGRAM)
+TRACELOG_CB(TRACE_DEBUG_PROCESS)
+TRACELOG_CB(TRACE_DEBUG_MODULE)
+TRACELOG_CB(TRACE_DEBUG_UNIT)
+TRACELOG_CB(TRACE_DEBUG_FUNCTION)
+TRACELOG_CB(TRACE_DEBUG_LINE)
+TRACELOG_CB(TRACE_DEBUG)