Skip to content

Commit

Permalink
normalize log level (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
birdstorm authored Apr 5, 2020
1 parent 8171a17 commit 7881968
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dbms/src/Server/ExtractFromConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,35 @@
#include <Poco/FormattingChannel.h>
#include <Poco/PatternFormatter.h>
#include <Poco/AutoPtr.h>
#include <Poco/String.h>

#include <Common/Config/ConfigProcessor.h>
#include <Common/Exception.h>
#include <Common/Config/TOMLConfiguration.h>


static std::string normalize(const std::string & log_level)
{
std::string norm = Poco::toLower(log_level);
// normalize
// info -> information
// warn -> warning
if (norm == "info")
return "information";
else if (norm == "warn")
return "warning";
else
return norm;
}

static void setupLogging(const std::string & log_level)
{
Poco::AutoPtr<Poco::ConsoleChannel> channel(new Poco::ConsoleChannel);
Poco::AutoPtr<Poco::PatternFormatter> formatter(new Poco::PatternFormatter);
formatter->setProperty("pattern", "%L%Y-%m-%d %H:%M:%S.%i <%p> %s: %t");
Poco::AutoPtr<Poco::FormattingChannel> formatting_channel(new Poco::FormattingChannel(formatter, channel));
Poco::Logger::root().setChannel(formatting_channel);
Poco::Logger::root().setLevel(log_level);
Poco::Logger::root().setLevel(normalize(log_level));
}

static std::string extractFromConfig(
Expand Down

0 comments on commit 7881968

Please sign in to comment.