* Loglevel information.
*/
enum lttng_loglevel_type {
- LTTNG_EVENT_LOGLEVEL = 0,
- LTTNG_EVENT_LOGLEVEL_ONLY = 1,
+ LTTNG_EVENT_LOGLEVEL_ALL = 0,
+ LTTNG_EVENT_LOGLEVEL_RANGE = 1,
+ LTTNG_EVENT_LOGLEVEL_SINGLE = 2,
};
/*
char name[LTTNG_SYMBOL_NAME_LEN];
enum lttng_loglevel_type loglevel_type;
- char loglevel[LTTNG_SYMBOL_NAME_LEN]; /* '\0' for all loglevels */
+ int loglevel;
- int64_t loglevel_value; /* for printing */
uint32_t enabled;
pid_t pid;
/* Per event type configuration */
};
enum lttng_ust_loglevel_type {
- LTTNG_UST_LOGLEVEL = 0,
- LTTNG_UST_LOGLEVEL_ONLY = 1,
+ LTTNG_UST_LOGLEVEL_ALL = 0,
+ LTTNG_UST_LOGLEVEL_RANGE = 1,
+ LTTNG_UST_LOGLEVEL_SINGLE = 2,
};
enum lttng_ust_output {
char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */
enum lttng_ust_loglevel_type loglevel_type;
- char loglevel[LTTNG_UST_SYM_NAME_LEN]; /* loglevel name */
+ int loglevel; /* value, -1: all */
/* Per instrumentation type configuration */
union {
struct lttng_ust_tracepoint_iter {
char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */
- char loglevel[LTTNG_UST_SYM_NAME_LEN]; /* loglevel */
- int64_t loglevel_value;
+ int loglevel;
};
struct lttng_ust_object_data {
tmp[i].type = LTTNG_EVENT_FUNCTION;
break;
}
- strncpy(tmp[i].loglevel, uevent->attr.loglevel, LTTNG_SYMBOL_NAME_LEN);
- tmp[i].loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+ tmp[i].loglevel = uevent->attr.loglevel;
switch (uevent->attr.loglevel_type) {
- case LTTNG_UST_LOGLEVEL:
- tmp[i].type = LTTNG_EVENT_LOGLEVEL;
+ case LTTNG_UST_LOGLEVEL_ALL:
+ tmp[i].type = LTTNG_EVENT_LOGLEVEL_ALL;
break;
- case LTTNG_UST_LOGLEVEL_ONLY:
- tmp[i].type = LTTNG_EVENT_LOGLEVEL_ONLY;
+ case LTTNG_UST_LOGLEVEL_RANGE:
+ tmp[i].type = LTTNG_EVENT_LOGLEVEL_RANGE;
+ break;
+ case LTTNG_UST_LOGLEVEL_SINGLE:
+ tmp[i].type = LTTNG_EVENT_LOGLEVEL_SINGLE;
break;
}
i++;
lue->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
switch (ev->loglevel_type) {
- case LTTNG_EVENT_LOGLEVEL:
- lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL;
+ case LTTNG_EVENT_LOGLEVEL_ALL:
+ lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ALL;
break;
- case LTTNG_EVENT_LOGLEVEL_ONLY:
- lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ONLY;
+ case LTTNG_EVENT_LOGLEVEL_RANGE:
+ lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_RANGE;
+ break;
+ case LTTNG_EVENT_LOGLEVEL_SINGLE:
+ lue->attr.loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE;
break;
default:
ERR("Unknown ust loglevel type (%d)", ev->type);
goto error_free_event;
}
- /* Copy loglevel name */
- strncpy(lue->attr.loglevel, ev->loglevel, LTTNG_UST_SYM_NAME_LEN);
- lue->attr.loglevel[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+ /* Copy loglevel */
+ lue->attr.loglevel = ev->loglevel;
/* Init node */
lttng_ht_node_init_str(&lue->node, lue->attr.name);
}
}
memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
- memcpy(tmp[count].loglevel, uiter.loglevel, LTTNG_UST_SYM_NAME_LEN);
+ tmp[count].loglevel = uiter.loglevel;
tmp[count].type = LTTNG_UST_TRACEPOINT;
- tmp[count].loglevel_value = uiter.loglevel_value;
tmp[count].pid = app->key.pid;
tmp[count].enabled = -1;
count++;
return ret;
}
+/*
+ * Maps this from string to value
+ *
+ * TRACE_EMERG = 0,
+ * TRACE_ALERT = 1,
+ * TRACE_CRIT = 2,
+ * TRACE_ERR = 3,
+ * TRACE_WARNING = 4,
+ * TRACE_NOTICE = 5,
+ * TRACE_INFO = 6,
+ * TRACE_SYSTEM = 7,
+ * TRACE_PROCESS = 8,
+ * TRACE_MODULE = 9,
+ * TRACE_UNIT = 10,
+ * TRACE_CLASS = 11,
+ * TRACE_OBJECT = 12,
+ * TRACE_FUNCTION = 13,
+ * TRACE_PRINTF = 14,
+ * TRACE_DEBUG = 15,
+ */
+static
+int loglevel_str_to_value(const char *str)
+{
+ if (!strcmp(str, "TRACE_EMERG")) {
+ return 0;
+ } else if (!strcmp(str, "TRACE_ALERT")) {
+ return 1;
+ } else if (!strcmp(str, "TRACE_CRIT")) {
+ return 2;
+ } else if (!strcmp(str, "TRACE_ERR")) {
+ return 3;
+ } else if (!strcmp(str, "TRACE_WARNING")) {
+ return 4;
+ } else if (!strcmp(str, "TRACE_NOTICE")) {
+ return 5;
+ } else if (!strcmp(str, "TRACE_INFO")) {
+ return 6;
+ } else if (!strcmp(str, "TRACE_SYSTEM")) {
+ return 7;
+ } else if (!strcmp(str, "TRACE_PROCESS")) {
+ return 8;
+ } else if (!strcmp(str, "TRACE_MODULE")) {
+ return 9;
+ } else if (!strcmp(str, "TRACE_UNIT")) {
+ return 10;
+ } else if (!strcmp(str, "TRACE_CLASS")) {
+ return 11;
+ } else if (!strcmp(str, "TRACE_OBJECT")) {
+ return 12;
+ } else if (!strcmp(str, "TRACE_FUNCTION")) {
+ return 13;
+ } else if (!strcmp(str, "TRACE_PRINTF")) {
+ return 14;
+ } else if (!strcmp(str, "TRACE_DEBUG")) {
+ return 15;
+ } else {
+ return -1;
+ }
+}
+
/*
* Enabling event using the lttng API.
*/
}
/* kernel loglevels not implemented */
- ev.loglevel_type = opt_loglevel_type;
- ev.loglevel[0] = '\0';
+ ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
} else if (opt_userspace) { /* User-space tracer action */
#if 0
if (opt_cmd_name != NULL || opt_pid) {
ev.loglevel_type = opt_loglevel_type;
if (opt_loglevel) {
- strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN);
- ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
- } else {
- ev.loglevel[0] = '\0';
+ ev.loglevel = loglevel_str_to_value(opt_loglevel);
+ if (ev.loglevel == -1) {
+ ERR("Unknown loglevel %s", opt_loglevel);
+ goto error;
+ }
}
} else {
ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
opt_userspace = 1;
break;
case OPT_LOGLEVEL:
- opt_loglevel_type = LTTNG_EVENT_LOGLEVEL;
+ opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
opt_loglevel = poptGetOptArg(pc);
break;
case OPT_LOGLEVEL_ONLY:
- opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_ONLY;
+ opt_loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
opt_loglevel = poptGetOptArg(pc);
break;
case OPT_LIST_OPTIONS:
}
static
-const char *loglevel_string_pre(const char *loglevel)
+const char *loglevel_string_pre(int loglevel)
{
- if (loglevel[0] == '\0') {
+ if (loglevel == -1) {
return "";
} else {
return " (loglevel: ";
}
static
-const char *loglevel_string_post(const char *loglevel)
+const char *loglevel_string_post(int loglevel)
{
- if (loglevel[0] == '\0') {
+ if (loglevel == -1) {
return "";
} else {
return ")";
}
}
+static const char *loglevel_string(int value)
+{
+ switch (value) {
+ case -1: return "";
+ case 0: return "TRACE_EMERG";
+ case 1: return "TRACE_ALERT";
+ case 2: return "TRACE_CRIT";
+ case 3: return "TRACE_ERR";
+ case 4: return "TRACE_WARNING";
+ case 5: return "TRACE_NOTICE";
+ case 6: return "TRACE_INFO";
+ case 7: return "TRACE_SYSTEM";
+ case 8: return "TRACE_PROCESS";
+ case 9: return "TRACE_MODULE";
+ case 10: return "TRACE_UNIT";
+ case 11: return "TRACE_CLASS";
+ case 12: return "TRACE_OBJECT";
+ case 13: return "TRACE_FUNCTION";
+ case 14: return "TRACE_PRINTF";
+ case 15: return "TRACE_DEBUG";
+ default: return "<<UNKNOWN>>";
+ }
+}
+
/*
* Pretty print single event.
*/
switch (event->type) {
case LTTNG_EVENT_TRACEPOINT:
{
- char ll_value[LTTNG_SYMBOL_NAME_LEN] = "";
-
- if (event->loglevel[0] != '\0') {
- int ret;
-
- ret = snprintf(ll_value, LTTNG_SYMBOL_NAME_LEN,
- " (%lld)", (long long) event->loglevel_value);
- if (ret < 0) {
- ERR("snprintf error");
- }
- }
- MSG("%s%s%s%s%s%s (type: tracepoint)%s", indent6,
+ MSG("%s%s%s%s%d%s (type: tracepoint)%s", indent6,
event->name,
loglevel_string_pre(event->loglevel),
+ loglevel_string(event->loglevel),
event->loglevel,
- ll_value,
loglevel_string_post(event->loglevel),
enabled_string(event->enabled));
break;
/* Spawn session daemon if needed */
if (opt_no_sessiond == 0 && check_args_no_sessiond(argc, argv) == 0 &&
(check_sessiond() < 0)) {
+ ret = 1;
goto error;
}
/* No leftovers, print usage and quit */
if ((argc - optind) == 0) {
usage(stderr);
+ ret = 1;
goto error;
}
memset(&event, 0, sizeof(struct lttng_event));
event.type = LTTNG_EVENT_TRACEPOINT;
- event.loglevel[0] = '\0';
- event.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+ event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
printf("\nTesting tracing all UST events:\n");
printf("-----------\n");
strcpy(ev1.name, "tp1");
ev1.type = LTTNG_EVENT_TRACEPOINT;
- ev1.loglevel[0] = '\0';
- ev1.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+ ev1.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
strcpy(ev2.name, "ev2");
ev2.type = LTTNG_EVENT_TRACEPOINT;
- ev2.loglevel[0] = '\0';
- ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+ ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
strcpy(ev3.name, "ev3");
ev3.type = LTTNG_EVENT_TRACEPOINT;
- ev3.loglevel[0] = '\0';
- ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL;
+ ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
printf("\nTesting tracing UST events:\n");
printf("-----------\n");