diff --git a/src/Interpreters/InternalTextLogsQueue.cpp b/src/Interpreters/InternalTextLogsQueue.cpp index 8e689069cec6..3be58a11beba 100644 --- a/src/Interpreters/InternalTextLogsQueue.cpp +++ b/src/Interpreters/InternalTextLogsQueue.cpp @@ -46,24 +46,25 @@ void InternalTextLogsQueue::pushBlock(Block && log_block) LOG_WARNING(&Poco::Logger::get("InternalTextLogsQueue"), "Log block have different structure"); } -const char * InternalTextLogsQueue::getPriorityName(int priority) +std::string_view InternalTextLogsQueue::getPriorityName(int priority) { - /// See Poco::Message::Priority + using namespace std::literals; - static constexpr const char * const PRIORITIES[] = + /// See Poco::Message::Priority + static constexpr std::array PRIORITIES = { - "Unknown", - "Fatal", - "Critical", - "Error", - "Warning", - "Notice", - "Information", - "Debug", - "Trace" + "Unknown"sv, + "Fatal"sv, + "Critical"sv, + "Error"sv, + "Warning"sv, + "Notice"sv, + "Information"sv, + "Debug"sv, + "Trace"sv, + "Test"sv, }; - - return (priority >= 1 && priority <= 8) ? PRIORITIES[priority] : PRIORITIES[0]; + return (priority >= 1 && priority < static_cast(PRIORITIES.size())) ? PRIORITIES[priority] : PRIORITIES[0]; } bool InternalTextLogsQueue::isNeeded(int priority, const String & source) const diff --git a/src/Interpreters/InternalTextLogsQueue.h b/src/Interpreters/InternalTextLogsQueue.h index 9c3c9f9e7073..bbe41ca33fe3 100644 --- a/src/Interpreters/InternalTextLogsQueue.h +++ b/src/Interpreters/InternalTextLogsQueue.h @@ -24,7 +24,7 @@ class InternalTextLogsQueue : public ConcurrentBoundedQueue void pushBlock(Block && log_block); /// Converts priority from Poco::Message::Priority to a string - static const char * getPriorityName(int priority); + static std::string_view getPriorityName(int priority); void setSourceRegexp(const String & regexp); private: diff --git a/tests/queries/0_stateless/02532_send_logs_level_test.reference b/tests/queries/0_stateless/02532_send_logs_level_test.reference new file mode 100644 index 000000000000..e3378ac8c3d1 --- /dev/null +++ b/tests/queries/0_stateless/02532_send_logs_level_test.reference @@ -0,0 +1,3 @@ + MergeTreeBaseSelectProcessor: PREWHERE actions: + MergeTreeRangeReader: First reader returned: num_rows: 1, columns: 1, total_rows_per_granule: 1, no filter, column[0]: Int32(size = 1), requested columns: key + MergeTreeRangeReader: read() returned num_rows: 1, columns: 1, total_rows_per_granule: 1, no filter, column[0]: Int32(size = 1), sample block key diff --git a/tests/queries/0_stateless/02532_send_logs_level_test.sh b/tests/queries/0_stateless/02532_send_logs_level_test.sh new file mode 100755 index 000000000000..7dd9a152385d --- /dev/null +++ b/tests/queries/0_stateless/02532_send_logs_level_test.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Tags: no-s3-storage, no-debug +# - no-s3-storage - S3 has additional logging +# - no-debug - debug builds also has additional logging + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +$CLICKHOUSE_CLIENT -nm -q " + drop table if exists data; + create table data (key Int) engine=MergeTree order by tuple(); + insert into data values (1); +" + +# NOTE: boost multitoken (--allow_repeated_settings) could prefer "first" +# instead of "last" value, hence you cannot simply append another +# --send_logs_level here. +CLICKHOUSE_CLIENT_CLEAN=$(echo ${CLICKHOUSE_CLIENT} | sed 's/'"--send_logs_level=${CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL}"'/--send_logs_level=test/g') +$CLICKHOUSE_CLIENT_CLEAN -q "select * from data" |& grep -o -e '.*' -e '.*' + +$CLICKHOUSE_CLIENT -q "drop table data"