]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add some terminal stuff
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 7 Jun 2022 18:50:52 +0000 (19:50 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 7 Jun 2022 21:10:50 +0000 (22:10 +0100)
src/client/rspamc.cxx
src/libstat/CMakeLists.txt

index eb82b02086c3a6dae0c2fb0ca884bafa69db3f01..283e8d2a1b09153dfb0e794d45b6d494c23a8ab6 100644 (file)
@@ -751,7 +751,8 @@ rspamc_metric_output(FILE *out, const ucl_object_t *obj)
        auto print_protocol_string = [&](const char *ucl_name, const char *output_message) {
                auto *elt = ucl_object_lookup(obj, ucl_name);
                if (elt) {
-                       fmt::print(out, "{}: {}\n", output_message, ucl_object_tostring(elt));
+                       fmt::print(out, "{}: {}\n", output_message,
+                                       fmt::format(fmt::emphasis::bold, "{}", ucl_object_tostring(elt)));
                }
        };
 
@@ -1115,17 +1116,19 @@ rspamc_stat_actions(ucl_object_t *obj, std::string &out, std::int64_t scanned)
                if (actions && ucl_object_type(actions) == UCL_OBJECT) {
                        while ((cur = ucl_object_iterate (actions, &iter, true)) != nullptr) {
                                auto cnt = ucl_object_toint(cur);
-                               fmt::format_to(std::back_inserter(out), "Messages with action {}: {}, {:.2f}%",
-                                               ucl_object_key(cur), cnt,
+                               fmt::format_to(std::back_inserter(out), "Messages with action {}: {}, {:.2f}%\n",
+                                               ucl_object_key(cur), fmt::format(fmt::emphasis::bold, "{}", cnt),
                                                ((double) cnt / (double) scanned) * 100.);
                        }
                }
 
                auto spam = ucl_object_toint(ucl_object_lookup(obj, "spam_count"));
                auto ham = ucl_object_toint(ucl_object_lookup(obj, "ham_count"));
-               fmt::format_to(std::back_inserter(out), "Messages treated as spam: {}, {:.2f}%\n", spam,
+               fmt::format_to(std::back_inserter(out), "Messages treated as spam: {}, {:.2f}%\n",
+                               fmt::format(fmt::emphasis::bold, "{}", ham),
                                ((double) spam / (double) scanned) * 100.);
-               fmt::format_to(std::back_inserter(out), "Messages treated as ham: {}, {:.2f}%\n", ham,
+               fmt::format_to(std::back_inserter(out), "Messages treated as ham: {}, {:.2f}%\n",
+                                          fmt::format(fmt::emphasis::bold, "{}", ham),
                                ((double) ham / (double) scanned) * 100.);
        }
 }
@@ -1167,16 +1170,17 @@ rspamc_stat_output(FILE *out, ucl_object_t *obj)
        out_str.reserve(8192);
 
        auto scanned = ucl_object_toint(ucl_object_lookup(obj, "scanned"));
-       fmt::format_to(std::back_inserter(out_str), "Messages scanned: {}\n", scanned);
+       fmt::format_to(std::back_inserter(out_str), "Messages scanned: {}\n",
+                                  fmt::format(fmt::emphasis::bold, "{}", scanned));
 
        rspamc_stat_actions(obj, out_str, scanned);
 
        fmt::format_to(std::back_inserter(out_str), "Messages learned: {}\n",
-                       ucl_object_toint(ucl_object_lookup(obj, "learned")));
+                       fmt::format(fmt::emphasis::bold, "{}", ucl_object_toint(ucl_object_lookup(obj, "learned"))));
        fmt::format_to(std::back_inserter(out_str), "Connections count: {}\n",
-                       ucl_object_toint(ucl_object_lookup(obj, "connections")));
+                       fmt::format(fmt::emphasis::bold, "{}",ucl_object_toint(ucl_object_lookup(obj, "connections"))));
        fmt::format_to(std::back_inserter(out_str), "Control connections count: {}\n",
-                       ucl_object_toint(ucl_object_lookup(obj, "control_connections")));
+                       fmt::format(fmt::emphasis::bold, "{}",ucl_object_toint(ucl_object_lookup(obj, "control_connections"))));
 
        const auto *avg_time_obj = ucl_object_lookup(obj, "scan_times");
 
@@ -1196,7 +1200,7 @@ rspamc_stat_output(FILE *out, ucl_object_t *obj)
                if (cnt > 0) {
                        auto sum = rspamd_sum_floats(nums.data(), &cnt);
                        fmt::format_to(std::back_inserter(out_str),
-                                                  "Average scan time: {:.3f} sec\n", sum / cnt);
+                                                  "Average scan time: {} sec\n", fmt::format(fmt::emphasis::bold, "{:.3f}", sum / cnt));
                }
        }
 
@@ -1562,13 +1566,13 @@ rspamc_client_cb(struct rspamd_client_connection *conn,
                        if (cmd.need_input && !json) {
                                if (!compact) {
                                        fmt::print(out, "Results for file: {} ({:.3} seconds)\n",
-                                                       cbdata->filename, diff);
+                                                       fmt::format(fmt::emphasis::bold, "{}", cbdata->filename), diff);
                                }
                        }
                        else {
                                if (!compact && !json) {
                                        fmt::print(out, "Results for command: {} ({:.3} seconds)\n",
-                                                       cmd.name, diff);
+                                                       fmt::format(fmt::emphasis::bold, "{}", cmd.name), diff);
                                }
                        }
 
index 19962239d14f4e74a866718f996a9344a0cc546f..b1df5c1e621eecdf4b53a69bc026c9e6ba1313ca 100644 (file)
@@ -11,6 +11,7 @@ SET(CLASSIFIERSSRC    ${CMAKE_CURRENT_SOURCE_DIR}/classifiers/bayes.c
 SET(BACKENDSSRC        ${CMAKE_CURRENT_SOURCE_DIR}/backends/mmaped_file.c
                                        ${CMAKE_CURRENT_SOURCE_DIR}/backends/sqlite3_backend.c
                                        ${CMAKE_CURRENT_SOURCE_DIR}/backends/cdb_backend.cxx
+                                       ${CMAKE_CURRENT_SOURCE_DIR}/backends/http_backend.cxx
                                        ${CMAKE_CURRENT_SOURCE_DIR}/backends/redis_backend.c)
 
 SET(CACHESSRC  ${CMAKE_CURRENT_SOURCE_DIR}/learn_cache/sqlite3_cache.c