mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Daemon: added formatting for console logger.
This commit is contained in:
parent
fb1e8d8b75
commit
e673533a0b
@ -108,6 +108,7 @@ void Daemon::reloadConfiguration()
|
|||||||
void Daemon::buildLoggers()
|
void Daemon::buildLoggers()
|
||||||
{
|
{
|
||||||
Poco::ScopedRWLock lock(*this);
|
Poco::ScopedRWLock lock(*this);
|
||||||
|
std::string format("%Y.%m.%d %H:%M:%S [ %I ] <%p> %s: %t");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -120,9 +121,6 @@ void Daemon::buildLoggers()
|
|||||||
// splitter
|
// splitter
|
||||||
SplitterChannel *split = new SplitterChannel();
|
SplitterChannel *split = new SplitterChannel();
|
||||||
|
|
||||||
// format
|
|
||||||
std::string format("%Y.%m.%d %H:%M:%S [ %I ] <%p> %s: %t");
|
|
||||||
|
|
||||||
// set up two channel chains
|
// set up two channel chains
|
||||||
PatternFormatter *pf = new PatternFormatter(format);
|
PatternFormatter *pf = new PatternFormatter(format);
|
||||||
pf->setProperty("times", "local");
|
pf->setProperty("times", "local");
|
||||||
@ -157,23 +155,33 @@ void Daemon::buildLoggers()
|
|||||||
|
|
||||||
split->open();
|
split->open();
|
||||||
logger().close();
|
logger().close();
|
||||||
logger().setChannel( split );
|
logger().setChannel(split);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Выводим на консоль
|
// Выводим на консоль
|
||||||
ConsoleChannel *file = new ConsoleChannel();
|
ConsoleChannel * file = new ConsoleChannel();
|
||||||
|
PatternFormatter * pf = new PatternFormatter(format);
|
||||||
|
pf->setProperty("times", "local");
|
||||||
|
FormattingChannel * log = new FormattingChannel(pf);
|
||||||
|
log->setChannel(file);
|
||||||
|
|
||||||
logger().close();
|
logger().close();
|
||||||
logger().setChannel( file );
|
logger().setChannel(log);
|
||||||
logger().warning("Logging to console");
|
logger().warning("Logging to console");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
// Выводим на консоль
|
// Выводим на консоль
|
||||||
ConsoleChannel *file = new ConsoleChannel();
|
ConsoleChannel * file = new ConsoleChannel();
|
||||||
|
PatternFormatter * pf = new PatternFormatter(format);
|
||||||
|
pf->setProperty("times", "local");
|
||||||
|
FormattingChannel * log = new FormattingChannel(pf);
|
||||||
|
log->setChannel(file);
|
||||||
|
|
||||||
logger().close();
|
logger().close();
|
||||||
logger().setChannel( file );
|
logger().setChannel(log);
|
||||||
logger().warning("Can't log to file. Logging to console");
|
logger().warning("Can't log to file. Logging to console");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user