提交 11fc35e0 编写于 作者: A Alexey Milovidov

Fixed accidential incompatibility due to wrong implementation of "send_logs_level" setting

上级 1b0ae80a
...@@ -164,10 +164,10 @@ void TCPHandler::runImpl() ...@@ -164,10 +164,10 @@ void TCPHandler::runImpl()
/// Should we send internal logs to client? /// Should we send internal logs to client?
if (client_revision >= DBMS_MIN_REVISION_WITH_SERVER_LOGS if (client_revision >= DBMS_MIN_REVISION_WITH_SERVER_LOGS
&& query_context.getSettingsRef().send_logs_level.value != "none") && query_context.getSettingsRef().send_logs_level.value != LogsLevel::none)
{ {
state.logs_queue = std::make_shared<InternalTextLogsQueue>(); state.logs_queue = std::make_shared<InternalTextLogsQueue>();
state.logs_queue->max_priority = Poco::Logger::parseLevel(query_context.getSettingsRef().send_logs_level.value); state.logs_queue->max_priority = Poco::Logger::parseLevel(query_context.getSettingsRef().send_logs_level.toString());
CurrentThread::attachInternalTextLogsQueue(state.logs_queue); CurrentThread::attachInternalTextLogsQueue(state.logs_queue);
} }
......
...@@ -280,7 +280,7 @@ struct Settings ...@@ -280,7 +280,7 @@ struct Settings
M(SettingBool, log_profile_events, true, "Log query performance statistics into the query_log and query_thread_log.") \ M(SettingBool, log_profile_events, true, "Log query performance statistics into the query_log and query_thread_log.") \
M(SettingBool, log_query_settings, true, "Log query settings into the query_log.") \ M(SettingBool, log_query_settings, true, "Log query settings into the query_log.") \
M(SettingBool, log_query_threads, true, "Log query threads into system.query_thread_log table. This setting have effect only when 'log_queries' is true.") \ M(SettingBool, log_query_threads, true, "Log query threads into system.query_thread_log table. This setting have effect only when 'log_queries' is true.") \
M(SettingLogsLevel, send_logs_level, "none", "Send server text logs with specified minimum level to client. Valid values: 'trace', 'debug', 'information', 'warning', 'error', 'none'") \ M(SettingLogsLevel, send_logs_level, LogsLevel::none, "Send server text logs with specified minimum level to client. Valid values: 'trace', 'debug', 'information', 'warning', 'error', 'none'") \
M(SettingBool, enable_optimize_predicate_expression, 0, "If it is set to true, optimize predicates to subqueries.") \ M(SettingBool, enable_optimize_predicate_expression, 0, "If it is set to true, optimize predicates to subqueries.") \
\ \
M(SettingUInt64, low_cardinality_max_dictionary_size, 8192, "Maximum size (in rows) of shared global dictionary for LowCardinality type.") \ M(SettingUInt64, low_cardinality_max_dictionary_size, 8192, "Maximum size (in rows) of shared global dictionary for LowCardinality type.") \
......
...@@ -623,39 +623,39 @@ void SettingDateTimeInputFormat::write(WriteBuffer & buf) const ...@@ -623,39 +623,39 @@ void SettingDateTimeInputFormat::write(WriteBuffer & buf) const
} }
const std::vector<String> SettingLogsLevel::log_levels = SettingLogsLevel::Value SettingLogsLevel::getValue(const String & s)
{ {
"none", if (s == "none") return Value::none;
"trace", if (s == "error") return Value::error;
"debug", if (s == "warning") return Value::warning;
"information", if (s == "information") return Value::information;
"warning", if (s == "debug") return Value::debug;
"error" if (s == "trace") return Value::trace;
};
throw Exception("Unknown logs level: '" + s + "', must be one of: none, error, warning, information, debug, trace", ErrorCodes::BAD_ARGUMENTS);
}
SettingLogsLevel::SettingLogsLevel(const String & level) String SettingLogsLevel::toString() const
{ {
set(level); const char * strings[] = {"none", "error", "warning", "information", "debug", "trace"};
return strings[static_cast<size_t>(value)];
} }
void SettingLogsLevel::set(Value x)
void SettingLogsLevel::set(const String & level)
{ {
auto it = std::find(log_levels.begin(), log_levels.end(), level); value = x;
if (it == log_levels.end())
throw Exception("Log level '" + level + "' not allowed.", ErrorCodes::UNKNOWN_LOG_LEVEL);
value = *it;
changed = true; changed = true;
} }
void SettingLogsLevel::set(const Field & x)
void SettingLogsLevel::set(const Field & level)
{ {
set(safeGet<String>(level)); set(safeGet<const String &>(x));
} }
void SettingLogsLevel::set(const String & x)
{
set(getValue(x));
}
void SettingLogsLevel::set(ReadBuffer & buf) void SettingLogsLevel::set(ReadBuffer & buf)
{ {
...@@ -664,13 +664,6 @@ void SettingLogsLevel::set(ReadBuffer & buf) ...@@ -664,13 +664,6 @@ void SettingLogsLevel::set(ReadBuffer & buf)
set(x); set(x);
} }
String SettingLogsLevel::toString() const
{
return value;
}
void SettingLogsLevel::write(WriteBuffer & buf) const void SettingLogsLevel::write(WriteBuffer & buf) const
{ {
writeBinary(toString(), buf); writeBinary(toString(), buf);
......
...@@ -157,6 +157,7 @@ struct SettingFloat ...@@ -157,6 +157,7 @@ struct SettingFloat
}; };
/// TODO: X macro
enum class LoadBalancing enum class LoadBalancing
{ {
/// among replicas with a minimum number of errors selected randomly /// among replicas with a minimum number of errors selected randomly
...@@ -381,24 +382,38 @@ struct SettingDateTimeInputFormat ...@@ -381,24 +382,38 @@ struct SettingDateTimeInputFormat
}; };
enum class LogsLevel
{
none = 0, /// Disable
error,
warning,
information,
debug,
trace,
};
class SettingLogsLevel class SettingLogsLevel
{ {
public: public:
using Value = LogsLevel;
String value; Value value;
bool changed = false; bool changed = false;
static const std::vector<String> log_levels;
SettingLogsLevel(const String & level); SettingLogsLevel(Value x) : value(x) {}
operator String() const { return value; }
void set(const String & level); operator Value() const { return value; }
void set(const Field & level); SettingLogsLevel & operator= (Value x) { set(x); return *this; }
void set(ReadBuffer & buf);
static Value getValue(const String & s);
String toString() const; String toString() const;
void set(Value x);
void set(const Field & x);
void set(const String & x);
void set(ReadBuffer & buf);
void write(WriteBuffer & buf) const; void write(WriteBuffer & buf) const;
}; };
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册