Fix: sessiond: preserve jul/log4j domain loglevels
[lttng-tools.git] / src / bin / lttng / utils.cpp
index 5b0c461d98a2d8f58627e76e3c6695914f606194..df03b1127ed96be5b96614d57389d3c60dc719d8 100644 (file)
@@ -665,11 +665,10 @@ end:
 
 namespace {
 template <typename FilterFunctionType>
-session_list get_sessions(const FilterFunctionType& filter, bool return_first_match_only = false)
+lttng::cli::session_list get_sessions(const FilterFunctionType& filter,
+                                     bool return_first_match_only = false)
 {
-       session_list list;
-
-       {
+       lttng::cli::session_list list = []() {
                int list_ret;
                struct lttng_session *psessions;
 
@@ -680,8 +679,8 @@ session_list get_sessions(const FilterFunctionType& filter, bool return_first_ma
                                        static_cast<lttng_error_code>(list_ret));
                }
 
-               list = session_list(psessions, list_ret);
-       }
+               return lttng::cli::session_list(psessions, list_ret);
+       }();
 
        std::size_t write_to = 0;
        for (std::size_t read_from = 0; read_from < list.size(); ++read_from) {
@@ -696,7 +695,7 @@ session_list get_sessions(const FilterFunctionType& filter, bool return_first_ma
                ++write_to;
 
                if (return_first_match_only) {
-                       return session_list(std::move(list), 1);
+                       return lttng::cli::session_list(std::move(list), 1);
                }
        }
 
@@ -706,23 +705,23 @@ session_list get_sessions(const FilterFunctionType& filter, bool return_first_ma
 }
 } /* namespace */
 
-session_list list_sessions(const struct session_spec& spec)
+lttng::cli::session_list lttng::cli::list_sessions(const struct session_spec& spec)
 {
-       switch (spec.type) {
-       case session_spec::NAME:
+       switch (spec.type_) {
+       case lttng::cli::session_spec::type::NAME:
                if (spec.value == nullptr) {
                        const auto configured_name =
                                lttng::make_unique_wrapper<char, lttng::free>(get_session_name());
 
                        if (configured_name) {
-                               const struct session_spec new_spec = {
-                                       .type = session_spec::NAME, .value = configured_name.get()
-                               };
+                               const struct lttng::cli::session_spec new_spec(
+                                       lttng::cli::session_spec::type::NAME,
+                                       configured_name.get());
 
                                return list_sessions(new_spec);
                        }
 
-                       return session_list();
+                       return lttng::cli::session_list();
                }
 
                return get_sessions(
@@ -730,13 +729,13 @@ session_list list_sessions(const struct session_spec& spec)
                                return strcmp(session.name, spec.value) == 0;
                        },
                        true);
-       case session_spec::GLOB_PATTERN:
+       case lttng::cli::session_spec::type::GLOB_PATTERN:
                return get_sessions([&spec](const lttng_session& session) {
                        return fnmatch(spec.value, session.name, 0) == 0;
                });
-       case session_spec::ALL:
+       case lttng::cli::session_spec::type::ALL:
                return get_sessions([](const lttng_session&) { return true; });
        }
 
-       return session_list();
+       return lttng::cli::session_list();
 }
This page took 0.024825 seconds and 4 git commands to generate.