From 3a8590e1af4afd0a1e4c2bb0debfaaf2f6e3364f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Fri, 8 Dec 2023 07:32:45 -0500 Subject: [PATCH] tools/sclla-sstable: implement the getlogginglevels command --- test/nodetool/test_logging.py | 20 ++++++++++++++++++++ tools/scylla-nodetool.cc | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/nodetool/test_logging.py diff --git a/test/nodetool/test_logging.py b/test/nodetool/test_logging.py new file mode 100644 index 0000000000..1495b24b97 --- /dev/null +++ b/test/nodetool/test_logging.py @@ -0,0 +1,20 @@ +# +# Copyright 2023-present ScyllaDB +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# + +from rest_api_mock import expected_request + + +def test_getlogginglevels(nodetool): + res = nodetool("getlogginglevels", expected_requests=[ + expected_request("GET", "/storage_service/logging_level", + response=[{"key": "sstable", "value": "info"}, {"key": "cache", "value": "trace"}])]) + + assert res == \ +""" +Logger Name Log Level +sstable info +cache trace +""" diff --git a/tools/scylla-nodetool.cc b/tools/scylla-nodetool.cc index 6eb5cde373..2ea2a3423f 100644 --- a/tools/scylla-nodetool.cc +++ b/tools/scylla-nodetool.cc @@ -423,6 +423,21 @@ void flush_operation(scylla_rest_client& client, const bpo::variables_map& vm) { client.post(format("/storage_service/keyspace_flush/{}", keyspace), std::move(params)); } +void getlogginglevels_operation(scylla_rest_client& client, const bpo::variables_map& vm) { + auto res = client.get("/storage_service/logging_level"); + const auto row_format = "{:<50}{:>10}\n"; + fmt::print(std::cout, "\n"); + fmt::print(std::cout, fmt::runtime(row_format), "Logger Name", "Log Level"); + for (const auto& element : res.GetArray()) { + const auto& logger_obj = element.GetObject(); + fmt::print( + std::cout, + fmt::runtime(row_format), + rjson::to_string_view(logger_obj["key"]), + rjson::to_string_view(logger_obj["value"])); + } +} + void gettraceprobability_operation(scylla_rest_client& client, const bpo::variables_map& vm) { auto res = client.get("/storage_service/trace_probability"); fmt::print(std::cout, "Current trace probability: {}\n", res.GetDouble()); @@ -948,6 +963,16 @@ Fore more information, see: https://opensource.docs.scylladb.com/stable/operatin }, flush_operation }, + { + { + "getlogginglevels", + "Get the runtime logging levels", +R"( +Prints a table with the name and current logging level for each logger in ScyllaDB. +)", + }, + getlogginglevels_operation + }, { { "gettraceprobability",