mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 05:32:52 +00:00
Add log_comment setting
This commit is contained in:
parent
ed623a1c6a
commit
51cfbe8c2e
@ -324,6 +324,7 @@ class IColumn;
|
|||||||
M(Bool, log_profile_events, true, "Log query performance statistics into the query_log and query_thread_log.", 0) \
|
M(Bool, log_profile_events, true, "Log query performance statistics into the query_log and query_thread_log.", 0) \
|
||||||
M(Bool, log_query_settings, true, "Log query settings into the query_log.", 0) \
|
M(Bool, log_query_settings, true, "Log query settings into the query_log.", 0) \
|
||||||
M(Bool, log_query_threads, true, "Log query threads into system.query_thread_log table. This setting have effect only when 'log_queries' is true.", 0) \
|
M(Bool, log_query_threads, true, "Log query threads into system.query_thread_log table. This setting have effect only when 'log_queries' is true.", 0) \
|
||||||
|
M(String, log_comment, "comment: ", "Log comment format", 0) \
|
||||||
M(LogsLevel, send_logs_level, LogsLevel::fatal, "Send server text logs with specified minimum level to client. Valid values: 'trace', 'debug', 'information', 'warning', 'error', 'fatal', 'none'", 0) \
|
M(LogsLevel, send_logs_level, LogsLevel::fatal, "Send server text logs with specified minimum level to client. Valid values: 'trace', 'debug', 'information', 'warning', 'error', 'fatal', 'none'", 0) \
|
||||||
M(Bool, enable_optimize_predicate_expression, 1, "If it is set to true, optimize predicates to subqueries.", 0) \
|
M(Bool, enable_optimize_predicate_expression, 1, "If it is set to true, optimize predicates to subqueries.", 0) \
|
||||||
M(Bool, enable_optimize_predicate_expression_to_final_subquery, 1, "Allow push predicate to final subquery.", 0) \
|
M(Bool, enable_optimize_predicate_expression_to_final_subquery, 1, "Allow push predicate to final subquery.", 0) \
|
||||||
|
@ -158,6 +158,13 @@ static void logQuery(const String & query, const Context & context, bool interna
|
|||||||
const auto & initial_query_id = client_info.initial_query_id;
|
const auto & initial_query_id = client_info.initial_query_id;
|
||||||
const auto & current_user = client_info.current_user;
|
const auto & current_user = client_info.current_user;
|
||||||
|
|
||||||
|
const Settings & settings = context.getSettingsRef();
|
||||||
|
const auto & log_comment = settings.log_comment;
|
||||||
|
if (!log_comment.toString().empty())
|
||||||
|
{
|
||||||
|
query = query + log_comment;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_DEBUG(&Poco::Logger::get("executeQuery"), "(from {}{}{}, using {} parser) {}",
|
LOG_DEBUG(&Poco::Logger::get("executeQuery"), "(from {}{}{}, using {} parser) {}",
|
||||||
client_info.current_address.toString(),
|
client_info.current_address.toString(),
|
||||||
(current_user != "default" ? ", user: " + current_user : ""),
|
(current_user != "default" ? ", user: " + current_user : ""),
|
||||||
@ -171,6 +178,22 @@ static void logQuery(const String & query, const Context & context, bool interna
|
|||||||
"OpenTelemetry traceparent '{}'",
|
"OpenTelemetry traceparent '{}'",
|
||||||
client_info.client_trace_context.composeTraceparentHeader());
|
client_info.client_trace_context.composeTraceparentHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueryLogElement elem;
|
||||||
|
|
||||||
|
elem.type = QueryLogElementType::QUERY_START;
|
||||||
|
elem.event_time = current_time_us / 1000000;
|
||||||
|
elem.event_time_microseconds = current_time_us;
|
||||||
|
elem.query_start_time = current_time_us / 1000000;
|
||||||
|
elem.query_start_time_microseconds = current_time_us;
|
||||||
|
|
||||||
|
elem.current_database = context.getCurrentDatabase();
|
||||||
|
elem.query = query;
|
||||||
|
elem.normalized_query_hash = normalizedQueryHash(query);
|
||||||
|
|
||||||
|
elem.client_info = client_info;
|
||||||
|
if (auto query_log = context.getQueryLog())
|
||||||
|
query_log->add(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user