Skip to content

Commit

Permalink
Merge pull request ClickHouse#45273 from azat/fix-test-log-level
Browse files Browse the repository at this point in the history
Fix log level "Test" for send_logs_level in client
  • Loading branch information
antonio2368 authored Jan 20, 2023
2 parents b55c8dd + 1f9a65b commit 136e4ec
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
29 changes: 15 additions & 14 deletions src/Interpreters/InternalTextLogsQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(PRIORITIES.size())) ? PRIORITIES[priority] : PRIORITIES[0];
}

bool InternalTextLogsQueue::isNeeded(int priority, const String & source) const
Expand Down
2 changes: 1 addition & 1 deletion src/Interpreters/InternalTextLogsQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InternalTextLogsQueue : public ConcurrentBoundedQueue<MutableColumns>
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Test> MergeTreeBaseSelectProcessor: PREWHERE actions: <nullptr>
<Test> MergeTreeRangeReader: First reader returned: num_rows: 1, columns: 1, total_rows_per_granule: 1, no filter, column[0]: Int32(size = 1), requested columns: key
<Test> MergeTreeRangeReader: read() returned num_rows: 1, columns: 1, total_rows_per_granule: 1, no filter, column[0]: Int32(size = 1), sample block key
22 changes: 22 additions & 0 deletions tests/queries/0_stateless/02532_send_logs_level_test.sh
Original file line number Diff line number Diff line change
@@ -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 '<Unknown>.*' -e '<Test>.*'

$CLICKHOUSE_CLIENT -q "drop table data"

0 comments on commit 136e4ec

Please sign in to comment.