void TraceLog::createModule (const String& moduleName, const String& path, int level) { Poco::FormattingChannel* pFCFile = new Poco::FormattingChannel(new Poco::PatternFormatter("%Y-%m-%d %H:%M:%S.%c %N[%P]:%s:%p:%t")); pFCFile->setChannel(new Poco::FileChannel(path.getCStr())); pFCFile->open(); Poco::Logger& fileLogger = Poco::Logger::create(moduleName.getCStr(), pFCFile, level); }
CTraceLogger::~CTraceLogger() { Poco::Logger& logger = Poco::Logger::root(); if (logger.getChannel() != NULL) { Poco::FormattingChannel *channel = static_cast<Poco::FormattingChannel*>(logger.getChannel()); channel->close(); channel->setFormatter(NULL); channel->setChannel(NULL); } Poco::Logger::shutdown(); }
void TraceLog::createConsoleLogger(int level) { if (Poco::Logger::has("console") == NULL) { // set up two channel chains - one to the // console and the other one to a log file. Poco::FormattingChannel* pFCConsole = new Poco::FormattingChannel(new Poco::PatternFormatter("%Y-%m-%d %H:%M:%S.%c %N[%P]:%s:%p:%t")); pFCConsole->setChannel(new Poco::ConsoleChannel); pFCConsole->open(); Poco::Logger& consoleLogger = Poco::Logger::create("console", pFCConsole, level); } }