Daemon: added formatting for console logger.

This commit is contained in:
Alexey Milovidov 2010-12-22 17:59:56 +00:00
parent fb1e8d8b75
commit e673533a0b

View File

@ -108,6 +108,7 @@ void Daemon::reloadConfiguration()
void Daemon::buildLoggers()
{
Poco::ScopedRWLock lock(*this);
std::string format("%Y.%m.%d %H:%M:%S [ %I ] <%p> %s: %t");
try
{
@ -120,9 +121,6 @@ void Daemon::buildLoggers()
// splitter
SplitterChannel *split = new SplitterChannel();
// format
std::string format("%Y.%m.%d %H:%M:%S [ %I ] <%p> %s: %t");
// set up two channel chains
PatternFormatter *pf = new PatternFormatter(format);
pf->setProperty("times", "local");
@ -163,8 +161,13 @@ void Daemon::buildLoggers()
{
// Выводим на консоль
ConsoleChannel * file = new ConsoleChannel();
PatternFormatter * pf = new PatternFormatter(format);
pf->setProperty("times", "local");
FormattingChannel * log = new FormattingChannel(pf);
log->setChannel(file);
logger().close();
logger().setChannel( file );
logger().setChannel(log);
logger().warning("Logging to console");
}
}
@ -172,8 +175,13 @@ void Daemon::buildLoggers()
{
// Выводим на консоль
ConsoleChannel * file = new ConsoleChannel();
PatternFormatter * pf = new PatternFormatter(format);
pf->setProperty("times", "local");
FormattingChannel * log = new FormattingChannel(pf);
log->setChannel(file);
logger().close();
logger().setChannel( file );
logger().setChannel(log);
logger().warning("Can't log to file. Logging to console");
throw;
}