From: Michael Jeanson Date: Tue, 28 May 2024 21:18:35 +0000 (-0400) Subject: lttng: add-trigger: clarify terminology for log levels X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=11c87568cabf0dfb31a9b3daa45459e1a6e86064;p=lttng-tools.git lttng: add-trigger: clarify terminology for log levels To eliminate ambiguity in the code, the terminology for log levels has been updated. The previous terms "min" and "max" log levels have been replaced with "least_severe" and "most_severe" respectively. This change addresses the varying conventions across different logging domains, where numerical values for severity can either increase or decrease with severity. The new terminology provides clarity, making it easier to understand the severity levels regardless of the logging domain's convention. Change-Id: Ie90bcc8e4c07b8b7437d9580e166141fae5c6d2f Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/add_trigger.cpp b/src/bin/lttng/commands/add_trigger.cpp index a733bf57e..ad2fd47c1 100644 --- a/src/bin/lttng/commands/add_trigger.cpp +++ b/src/bin/lttng/commands/add_trigger.cpp @@ -238,84 +238,92 @@ static bool parse_log_level_string(const char *str, switch (event_rule_type) { case LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT: { - enum lttng_loglevel log_level_min, log_level_max; - if (!loglevel_parse_range_string(str, &log_level_min, &log_level_max)) { + enum lttng_loglevel log_level_least_severe, log_level_most_severe; + if (!loglevel_parse_range_string( + str, &log_level_least_severe, &log_level_most_severe)) { goto error; } /* Only support VAL and VAL.. for now. */ - if (log_level_min != log_level_max && log_level_max != LTTNG_LOGLEVEL_EMERG) { + if (log_level_least_severe != log_level_most_severe && + log_level_most_severe != LTTNG_LOGLEVEL_EMERG) { goto error; } - *log_level = (int) log_level_min; - *log_level_only = log_level_min == log_level_max; + *log_level = (int) log_level_least_severe; + *log_level_only = log_level_least_severe == log_level_most_severe; break; } case LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING: { - enum lttng_loglevel_log4j log_level_min, log_level_max; - if (!loglevel_log4j_parse_range_string(str, &log_level_min, &log_level_max)) { + enum lttng_loglevel_log4j log_level_least_severe, log_level_most_severe; + if (!loglevel_log4j_parse_range_string( + str, &log_level_least_severe, &log_level_most_severe)) { goto error; } /* Only support VAL and VAL.. for now. */ - if (log_level_min != log_level_max && log_level_max != LTTNG_LOGLEVEL_LOG4J_FATAL) { + if (log_level_least_severe != log_level_most_severe && + log_level_most_severe != LTTNG_LOGLEVEL_LOG4J_FATAL) { goto error; } - *log_level = (int) log_level_min; - *log_level_only = log_level_min == log_level_max; + *log_level = (int) log_level_least_severe; + *log_level_only = log_level_least_severe == log_level_most_severe; break; } case LTTNG_EVENT_RULE_TYPE_LOG4J2_LOGGING: { - enum lttng_loglevel_log4j2 log_level_min, log_level_max; - if (!loglevel_log4j2_parse_range_string(str, &log_level_min, &log_level_max)) { + enum lttng_loglevel_log4j2 log_level_least_severe, log_level_most_severe; + if (!loglevel_log4j2_parse_range_string( + str, &log_level_least_severe, &log_level_most_severe)) { goto error; } /* Only support VAL and VAL.. for now. */ - if (log_level_min != log_level_max && - log_level_max != LTTNG_LOGLEVEL_LOG4J2_FATAL) { + if (log_level_least_severe != log_level_most_severe && + log_level_most_severe != LTTNG_LOGLEVEL_LOG4J2_FATAL) { goto error; } - *log_level = (int) log_level_min; - *log_level_only = log_level_min == log_level_max; + *log_level = (int) log_level_least_severe; + *log_level_only = log_level_least_severe == log_level_most_severe; break; } case LTTNG_EVENT_RULE_TYPE_JUL_LOGGING: { - enum lttng_loglevel_jul log_level_min, log_level_max; - if (!loglevel_jul_parse_range_string(str, &log_level_min, &log_level_max)) { + enum lttng_loglevel_jul log_level_least_severe, log_level_most_severe; + if (!loglevel_jul_parse_range_string( + str, &log_level_least_severe, &log_level_most_severe)) { goto error; } /* Only support VAL and VAL.. for now. */ - if (log_level_min != log_level_max && log_level_max != LTTNG_LOGLEVEL_JUL_SEVERE) { + if (log_level_least_severe != log_level_most_severe && + log_level_most_severe != LTTNG_LOGLEVEL_JUL_SEVERE) { goto error; } - *log_level = (int) log_level_min; - *log_level_only = log_level_min == log_level_max; + *log_level = (int) log_level_least_severe; + *log_level_only = log_level_least_severe == log_level_most_severe; break; } case LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING: { - enum lttng_loglevel_python log_level_min, log_level_max; - if (!loglevel_python_parse_range_string(str, &log_level_min, &log_level_max)) { + enum lttng_loglevel_python log_level_least_severe, log_level_most_severe; + if (!loglevel_python_parse_range_string( + str, &log_level_least_severe, &log_level_most_severe)) { goto error; } /* Only support VAL and VAL.. for now. */ - if (log_level_min != log_level_max && - log_level_max != LTTNG_LOGLEVEL_PYTHON_CRITICAL) { + if (log_level_least_severe != log_level_most_severe && + log_level_most_severe != LTTNG_LOGLEVEL_PYTHON_CRITICAL) { goto error; } - *log_level = (int) log_level_min; - *log_level_only = log_level_min == log_level_max; + *log_level = (int) log_level_least_severe; + *log_level_only = log_level_least_severe == log_level_most_severe; break; } default: diff --git a/src/bin/lttng/loglevel.cpp b/src/bin/lttng/loglevel.cpp index cd7d2d28e..1ffd13c98 100644 --- a/src/bin/lttng/loglevel.cpp +++ b/src/bin/lttng/loglevel.cpp @@ -163,9 +163,9 @@ end: static bool loglevel_parse_range_string_common(const char *str, const struct loglevel_name_value *nvs, size_t nvs_count, - int default_max, - int *min, - int *max) + int default_most_severe, + int *least_severe, + int *most_severe) { bool ret; int i; @@ -190,18 +190,18 @@ static bool loglevel_parse_range_string_common(const char *str, } /* - * Record the min value and skip over the loglevel name found + * Record the least_severe value and skip over the loglevel name found * previously. */ - *min = nv->value; + *least_severe = nv->value; str += strlen(nv->name); /* * If we are at the end of 'str', only one loglevel name was specified, - * it is also the max. + * it is also the most_severe. */ if (*str == '\0') { - *max = nv->value; + *most_severe = nv->value; ret = true; goto end; } @@ -216,11 +216,11 @@ static bool loglevel_parse_range_string_common(const char *str, str += strlen(".."); /* - * If we are at the end of 'str' after the separator, set - * the default max value for the domain as the max. + * If we are at the end of 'str' after the separator, set the default + * most_severe value for the domain as the most_severe. */ if (*str == '\0') { - *max = default_max; + *most_severe = default_most_severe; ret = true; goto end; } @@ -244,9 +244,9 @@ static bool loglevel_parse_range_string_common(const char *str, } /* - * Record the max value for the loglevel found in 'str'. + * Record the most_severe value for the loglevel found in 'str'. */ - *max = nv->value; + *most_severe = nv->value; ret = true; goto end; @@ -271,19 +271,19 @@ int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel) } bool loglevel_parse_range_string(const char *str, - enum lttng_loglevel *min, - enum lttng_loglevel *max) + enum lttng_loglevel *least_severe, + enum lttng_loglevel *most_severe) { - int min_int, max_int; + int least_severe_int, most_severe_int; const bool ret = loglevel_parse_range_string_common(str, loglevel_values, ARRAY_SIZE(loglevel_values), LTTNG_LOGLEVEL_EMERG, - &min_int, - &max_int); + &least_severe_int, + &most_severe_int); - *min = (lttng_loglevel) min_int; - *max = (lttng_loglevel) max_int; + *least_severe = (lttng_loglevel) least_severe_int; + *most_severe = (lttng_loglevel) most_severe_int; return ret; } @@ -302,19 +302,19 @@ int loglevel_log4j_name_to_value(const char *name, enum lttng_loglevel_log4j *lo } bool loglevel_log4j_parse_range_string(const char *str, - enum lttng_loglevel_log4j *min, - enum lttng_loglevel_log4j *max) + enum lttng_loglevel_log4j *least_severe, + enum lttng_loglevel_log4j *most_severe) { - int min_int, max_int; + int least_severe_int, most_severe_int; const bool ret = loglevel_parse_range_string_common(str, loglevel_log4j_values, ARRAY_SIZE(loglevel_log4j_values), LTTNG_LOGLEVEL_LOG4J_FATAL, - &min_int, - &max_int); + &least_severe_int, + &most_severe_int); - *min = (lttng_loglevel_log4j) min_int; - *max = (lttng_loglevel_log4j) max_int; + *least_severe = (lttng_loglevel_log4j) least_severe_int; + *most_severe = (lttng_loglevel_log4j) most_severe_int; return ret; } @@ -333,19 +333,19 @@ int loglevel_log4j2_name_to_value(const char *name, enum lttng_loglevel_log4j2 * } bool loglevel_log4j2_parse_range_string(const char *str, - enum lttng_loglevel_log4j2 *min, - enum lttng_loglevel_log4j2 *max) + enum lttng_loglevel_log4j2 *least_severe, + enum lttng_loglevel_log4j2 *most_severe) { - int min_int, max_int; + int least_severe_int, most_severe_int; bool ret = loglevel_parse_range_string_common(str, loglevel_log4j2_values, ARRAY_SIZE(loglevel_log4j2_values), LTTNG_LOGLEVEL_LOG4J2_FATAL, - &min_int, - &max_int); + &least_severe_int, + &most_severe_int); - *min = (lttng_loglevel_log4j2) min_int; - *max = (lttng_loglevel_log4j2) max_int; + *least_severe = (lttng_loglevel_log4j2) least_severe_int; + *most_severe = (lttng_loglevel_log4j2) most_severe_int; return ret; } @@ -364,19 +364,19 @@ int loglevel_jul_name_to_value(const char *name, enum lttng_loglevel_jul *loglev } bool loglevel_jul_parse_range_string(const char *str, - enum lttng_loglevel_jul *min, - enum lttng_loglevel_jul *max) + enum lttng_loglevel_jul *least_severe, + enum lttng_loglevel_jul *most_severe) { - int min_int, max_int; + int least_severe_int, most_severe_int; const bool ret = loglevel_parse_range_string_common(str, loglevel_jul_values, ARRAY_SIZE(loglevel_jul_values), LTTNG_LOGLEVEL_JUL_SEVERE, - &min_int, - &max_int); + &least_severe_int, + &most_severe_int); - *min = (lttng_loglevel_jul) min_int; - *max = (lttng_loglevel_jul) max_int; + *least_severe = (lttng_loglevel_jul) least_severe_int; + *most_severe = (lttng_loglevel_jul) most_severe_int; return ret; } @@ -395,19 +395,19 @@ int loglevel_python_name_to_value(const char *name, enum lttng_loglevel_python * } bool loglevel_python_parse_range_string(const char *str, - enum lttng_loglevel_python *min, - enum lttng_loglevel_python *max) + enum lttng_loglevel_python *least_severe, + enum lttng_loglevel_python *most_severe) { - int min_int, max_int; + int least_severe_int, most_severe_int; const bool ret = loglevel_parse_range_string_common(str, loglevel_python_values, ARRAY_SIZE(loglevel_python_values), LTTNG_LOGLEVEL_PYTHON_CRITICAL, - &min_int, - &max_int); + &least_severe_int, + &most_severe_int); - *min = (lttng_loglevel_python) min_int; - *max = (lttng_loglevel_python) max_int; + *least_severe = (lttng_loglevel_python) least_severe_int; + *most_severe = (lttng_loglevel_python) most_severe_int; return ret; } diff --git a/src/bin/lttng/loglevel.hpp b/src/bin/lttng/loglevel.hpp index 0989ee60f..308c069bd 100644 --- a/src/bin/lttng/loglevel.hpp +++ b/src/bin/lttng/loglevel.hpp @@ -15,32 +15,32 @@ int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel); bool loglevel_parse_range_string(const char *str, - enum lttng_loglevel *min, - enum lttng_loglevel *max); + enum lttng_loglevel *least_severe, + enum lttng_loglevel *most_severe); int loglevel_log4j_name_to_value(const char *name, enum lttng_loglevel_log4j *loglevel); bool loglevel_log4j_parse_range_string(const char *str, - enum lttng_loglevel_log4j *min, - enum lttng_loglevel_log4j *max); + enum lttng_loglevel_log4j *least_severe, + enum lttng_loglevel_log4j *most_severe); int loglevel_log4j2_name_to_value(const char *name, enum lttng_loglevel_log4j2 *loglevel); bool loglevel_log4j2_parse_range_string(const char *str, - enum lttng_loglevel_log4j2 *min, - enum lttng_loglevel_log4j2 *max); + enum lttng_loglevel_log4j2 *least_severe, + enum lttng_loglevel_log4j2 *most_severe); int loglevel_jul_name_to_value(const char *name, enum lttng_loglevel_jul *loglevel); bool loglevel_jul_parse_range_string(const char *str, - enum lttng_loglevel_jul *min, - enum lttng_loglevel_jul *max); + enum lttng_loglevel_jul *least_severe, + enum lttng_loglevel_jul *most_severe); int loglevel_python_name_to_value(const char *name, enum lttng_loglevel_python *loglevel); bool loglevel_python_parse_range_string(const char *str, - enum lttng_loglevel_python *min, - enum lttng_loglevel_python *max); + enum lttng_loglevel_python *least_severe, + enum lttng_loglevel_python *most_severe); const char *loglevel_value_to_name(int loglevel);