Skip to content

Commit

Permalink
[CH] Format log output for CH backend (facebookincubator#1746)
Browse files Browse the repository at this point in the history
What changes were proposed in this pull request?
How was this patch tested?
manual tests
  • Loading branch information
exmy authored Jun 1, 2023
1 parent 40bebcc commit c5fe982
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 12 additions & 1 deletion cpp-ch/local-engine/Common/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@
#include <Poco/AsyncChannel.h>
#include <Poco/AutoPtr.h>
#include <Poco/ConsoleChannel.h>
#include <Poco/PatternFormatter.h>
#include <Poco/FormattingChannel.h>
#include <Poco/SimpleFileChannel.h>


using Poco::AsyncChannel;
using Poco::AutoPtr;
using Poco::ConsoleChannel;
using Poco::PatternFormatter;
using Poco::FormattingChannel;

void local_engine::Logger::initConsoleLogger(const std::string & level)
{
AutoPtr<ConsoleChannel> chan(new ConsoleChannel);
AutoPtr<AsyncChannel> async_chann(new AsyncChannel(chan));

AutoPtr<PatternFormatter> formatter(new PatternFormatter);
formatter->setProperty("pattern", "%Y-%m-%d %H:%M:%S.%i <%p> %s: %t");
formatter->setProperty("times", "local");

AutoPtr<FormattingChannel> format_channel(new FormattingChannel(formatter, chan));
AutoPtr<AsyncChannel> async_chann(new AsyncChannel(format_channel));

Poco::Logger::root().setChannel(async_chann);
Poco::Logger::root().setLevel(level);
}
Expand Down
8 changes: 4 additions & 4 deletions cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ QueryPlanPtr SerializedPlanParser::parse(std::unique_ptr<substrait::Plan> plan)
pb_util::JsonOptions options;
std::string json;
pb_util::MessageToJsonString(*plan, &json, options);
LOG_DEBUG(&Poco::Logger::get("SerializedPlanParser"), "substrait plan:{}", json);
LOG_DEBUG(&Poco::Logger::get("SerializedPlanParser"), "substrait plan:\n{}", json);
}
parseExtensions(plan->extensions());
if (plan->relations_size() == 1)
Expand Down Expand Up @@ -2009,7 +2009,7 @@ QueryPlanPtr SerializedPlanParser::parse(const std::string & plan)
if (logger->debug())
{
auto out = PlanUtil::explainPlan(*res);
LOG_DEBUG(logger, "clickhouse plan:{}", out);
LOG_DEBUG(logger, "clickhouse plan:\n{}", out);
}
return std::move(res);
}
Expand Down Expand Up @@ -2348,7 +2348,7 @@ ActionsDAGPtr ASTParser::convertToActions(const NamesAndTypesList & name_and_typ

ASTPtr ASTParser::parseToAST(const Names & names, const substrait::Expression & rel)
{
LOG_DEBUG(&Poco::Logger::get("ASTParser"), "substrait plan:{}", rel.DebugString());
LOG_DEBUG(&Poco::Logger::get("ASTParser"), "substrait plan:\n{}", rel.DebugString());
if (!rel.has_scalar_function())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "the root of expression should be a scalar function:\n {}", rel.DebugString());

Expand Down Expand Up @@ -2579,7 +2579,7 @@ void LocalExecutor::execute(QueryPlanPtr query_plan)
.compile_expressions = CompileExpressions::yes},
.process_list_element = query_status});
query_pipeline = QueryPipelineBuilder::getPipeline(std::move(*pipeline_builder));
LOG_DEBUG(&Poco::Logger::get("LocalExecutor"), "clickhouse pipeline:{}", QueryPipelineUtil::explainPipeline(query_pipeline));
LOG_DEBUG(&Poco::Logger::get("LocalExecutor"), "clickhouse pipeline:\n{}", QueryPipelineUtil::explainPipeline(query_pipeline));
auto t_pipeline = stopwatch.elapsedMicroseconds();
executor = std::make_unique<PullingPipelineExecutor>(query_pipeline);
auto t_executor = stopwatch.elapsedMicroseconds() - t_pipeline;
Expand Down

0 comments on commit c5fe982

Please sign in to comment.