#include "common/mi-lttng.h"
/* For lttng_condition_type_str(). */
#include "lttng/condition/condition-internal.h"
+#include "lttng/condition/on-event.h"
+#include "lttng/condition/on-event-internal.h"
/* For lttng_domain_type_str(). */
#include "lttng/domain-internal.h"
+#include "../loglevel.h"
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
ARGPAR_OPT_DESCR_SENTINEL,
};
+/*
+ * Returns the human-readable log level name associated with a numerical value
+ * if there is one. The Log4j and JUL domains have discontinuous log level
+ * values (a value can fall between two labels). In those cases, NULL is
+ * returned.
+ */
+static const char *get_pretty_loglevel_name(
+ enum lttng_domain_type domain, int loglevel)
+{
+ const char *name = NULL;
+
+ switch (domain) {
+ case LTTNG_DOMAIN_UST:
+ name = loglevel_value_to_name(loglevel);
+ break;
+ case LTTNG_DOMAIN_LOG4J:
+ name = loglevel_log4j_value_to_name(loglevel);
+ break;
+ case LTTNG_DOMAIN_JUL:
+ name = loglevel_jul_value_to_name(loglevel);
+ break;
+ case LTTNG_DOMAIN_PYTHON:
+ name = loglevel_python_value_to_name(loglevel);
+ break;
+ default:
+ break;
+ }
+
+ return name;
+}
+
static
void print_event_rule_tracepoint(const struct lttng_event_rule *event_rule)
{
const char *pattern;
const char *filter;
int log_level;
+ const struct lttng_log_level_rule *log_level_rule = NULL;
unsigned int exclusions_count;
int i;
assert(event_rule_status == LTTNG_EVENT_RULE_STATUS_UNSET);
}
- event_rule_status = lttng_event_rule_tracepoint_get_log_level(
- event_rule, &log_level);
+ event_rule_status = lttng_event_rule_tracepoint_get_log_level_rule(
+ event_rule, &log_level_rule);
if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) {
- enum lttng_loglevel_type log_level_type;
+ enum lttng_log_level_rule_status llr_status;
const char *log_level_op;
+ const char *pretty_loglevel_name;
+
+ switch (lttng_log_level_rule_get_type(log_level_rule)) {
+ case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
+ log_level_op = "is";
+ llr_status = lttng_log_level_rule_exactly_get_level(
+ log_level_rule, &log_level);
+ break;
+ case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
+ log_level_op = "at least";
+ llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
+ log_level_rule, &log_level);
+ break;
+ default:
+ abort();
+ }
- event_rule_status = lttng_event_rule_tracepoint_get_log_level_type(
- event_rule, &log_level_type);
- assert(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
- assert(log_level_type == LTTNG_EVENT_LOGLEVEL_RANGE ||
- log_level_type == LTTNG_EVENT_LOGLEVEL_SINGLE);
-
- log_level_op = (log_level_type == LTTNG_EVENT_LOGLEVEL_RANGE ? "<=" : "==");
+ assert(llr_status == LTTNG_LOG_LEVEL_RULE_STATUS_OK);
- _MSG(", log level %s %s", log_level_op,
- mi_lttng_loglevel_string(
- log_level, domain_type));
+ pretty_loglevel_name = get_pretty_loglevel_name(
+ domain_type, log_level);
+ if (pretty_loglevel_name) {
+ _MSG(", log level %s %s", log_level_op,
+ pretty_loglevel_name);
+ } else {
+ _MSG(", log level %s %d", log_level_op, log_level);
+ }
} else {
assert(event_rule_status == LTTNG_EVENT_RULE_STATUS_UNSET);
}
assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE);
- event_rule_status = lttng_event_rule_kernel_probe_get_name(event_rule, &name);
+ event_rule_status = lttng_event_rule_kernel_probe_get_event_name(event_rule, &name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to get kprobe event rule's name.");
goto end;
assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE);
- event_rule_status = lttng_event_rule_userspace_probe_get_name(event_rule, &name);
+ event_rule_status = lttng_event_rule_userspace_probe_get_event_name(
+ event_rule, &name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to get uprobe event rule's name.");
goto end;
const struct lttng_event_rule *event_rule;
enum lttng_condition_status condition_status;
unsigned int cap_desc_count, i;
+ uint64_t error_count;
condition_status =
lttng_condition_on_event_get_rule(condition, &event_rule);
condition, &cap_desc_count);
assert(condition_status == LTTNG_CONDITION_STATUS_OK);
+ error_count = lttng_condition_on_event_get_error_count(condition);
+ MSG(" tracer notifications discarded: %" PRIu64, error_count);
+
if (cap_desc_count > 0) {
MSG(" captures:");
{
enum lttng_action_type action_type;
enum lttng_action_status action_status;
+ const struct lttng_firing_policy *policy = NULL;
const char *value;
action_type = lttng_action_get_type(action);
switch (action_type) {
case LTTNG_ACTION_TYPE_NOTIFY:
- MSG("notify");
+ _MSG("notify");
+
+ action_status = lttng_action_notify_get_firing_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve firing policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_START_SESSION:
action_status = lttng_action_start_session_get_session_name(
action, &value);
assert(action_status == LTTNG_ACTION_STATUS_OK);
- MSG("start session `%s`", value);
+ _MSG("start session `%s`", value);
+
+ action_status = lttng_action_start_session_get_firing_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve firing policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_STOP_SESSION:
action_status = lttng_action_stop_session_get_session_name(
action, &value);
assert(action_status == LTTNG_ACTION_STATUS_OK);
- MSG("stop session `%s`", value);
+ _MSG("stop session `%s`", value);
+
+ action_status = lttng_action_stop_session_get_firing_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve firing policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_ROTATE_SESSION:
action_status = lttng_action_rotate_session_get_session_name(
action, &value);
assert(action_status == LTTNG_ACTION_STATUS_OK);
- MSG("rotate session `%s`", value);
+ _MSG("rotate session `%s`", value);
+
+ action_status = lttng_action_rotate_session_get_firing_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve firing policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_SNAPSHOT_SESSION:
{
}
}
- MSG("");
+ action_status = lttng_action_snapshot_session_get_firing_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve firing policy.");
+ goto end;
+ }
break;
}
-
default:
abort();
}
+
+ if (policy) {
+ enum lttng_firing_policy_type policy_type;
+ enum lttng_firing_policy_status policy_status;
+ uint64_t policy_value = 0;
+
+ policy_type = lttng_firing_policy_get_type(policy);
+
+ switch (policy_type) {
+ case LTTNG_FIRING_POLICY_TYPE_EVERY_N:
+ policy_status = lttng_firing_policy_every_n_get_interval(
+ policy, &policy_value);
+ if (policy_status != LTTNG_FIRING_POLICY_STATUS_OK) {
+ ERR("Failed to get action firing policy interval");
+ goto end;
+ }
+ if (policy_value > 1) {
+ /* The default is 1 so print only when it is a
+ * special case.
+ */
+ _MSG(", firing policy: after every %" PRIu64
+ " occurrences",
+ policy_value);
+ }
+ break;
+ case LTTNG_FIRING_POLICY_TYPE_ONCE_AFTER_N:
+ policy_status = lttng_firing_policy_once_after_n_get_threshold(
+ policy, &policy_value);
+ if (policy_status != LTTNG_FIRING_POLICY_STATUS_OK) {
+ ERR("Failed to get action firing policy interval");
+ goto end;
+ }
+ _MSG(", firing policy: once after %" PRIu64
+ " occurrences",
+ policy_value);
+ break;
+ default:
+ abort();
+ }
+ }
+
+ MSG("");
+end:
+ return;
}
static
enum lttng_action_type action_type;
enum lttng_trigger_status trigger_status;
const char *name;
- enum lttng_trigger_firing_policy firing_policy_type;
- uint64_t threshold;
uid_t trigger_uid;
trigger_status = lttng_trigger_get_name(trigger, &name);
MSG("- id: %s", name);
MSG(" user id: %d", trigger_uid);
- trigger_status = lttng_trigger_get_firing_policy(
- trigger, &firing_policy_type, &threshold);
- if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
- ERR("Failed to get trigger's policy.");
- goto end;
- }
-
- switch (firing_policy_type) {
- case LTTNG_TRIGGER_FIRING_POLICY_EVERY_N:
- if (threshold > 1) {
- MSG(" firing policy: after every %" PRIu64 " occurences", threshold);
- }
- break;
- case LTTNG_TRIGGER_FIRING_POLICY_ONCE_AFTER_N:
- MSG(" firing policy: once after %" PRIu64 " occurences", threshold);
- break;
- default:
- abort();
- }
-
condition = lttng_trigger_get_const_condition(trigger);
condition_type = lttng_condition_get_type(condition);
MSG(" condition: %s", lttng_condition_type_str(condition_type));
print_one_action(action);
}
-end:
- return;
}
static