Log query into text log (not into system table).
| 418 | |
| 419 | /// Log query into text log (not into system table). |
| 420 | static void logQuery(const String & query, ContextPtr context, bool internal) |
| 421 | { |
| 422 | if (internal) |
| 423 | { |
| 424 | LOG_DEBUG(&Poco::Logger::get("executeQuery"), "(internal) {}", joinLines(query)); |
| 425 | } |
| 426 | else |
| 427 | { |
| 428 | const auto & client_info = context->getClientInfo(); |
| 429 | |
| 430 | const auto & current_query_id = client_info.current_query_id; |
| 431 | const auto & initial_query_id = client_info.initial_query_id; |
| 432 | const auto & current_user = client_info.current_user; |
| 433 | |
| 434 | String comment = context->getSettingsRef().log_comment; |
| 435 | size_t max_query_size = context->getSettingsRef().max_query_size; |
| 436 | |
| 437 | if (comment.size() > max_query_size) |
| 438 | comment.resize(max_query_size); |
| 439 | |
| 440 | if (!comment.empty()) |
| 441 | comment = fmt::format(" (comment: {})", comment); |
| 442 | |
| 443 | LOG_DEBUG( |
| 444 | &Poco::Logger::get("executeQuery"), |
| 445 | "(from {}{}{}){} {}", |
| 446 | client_info.current_address.toString(), |
| 447 | (current_user != "default" ? ", user: " + current_user : ""), |
| 448 | (!initial_query_id.empty() && current_query_id != initial_query_id ? ", initial_query_id: " + initial_query_id : std::string()), |
| 449 | comment, |
| 450 | joinLines(query)); |
| 451 | |
| 452 | if (client_info.client_trace_context.trace_id != UUID()) |
| 453 | { |
| 454 | LOG_TRACE( |
| 455 | &Poco::Logger::get("executeQuery"), |
| 456 | "OpenTelemetry traceparent '{}'", |
| 457 | client_info.client_trace_context.composeTraceparentHeader()); |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | static void logQuery(ContextPtr context, const QueryLogElement & log_element) |
| 463 | { |
no test coverage detected