void ConverService::createLogger(const char* name) { char path[100]; sprintf_s(path, "./log/%s.log", name); LogHandlerPtr tasHandler = LogHandlerPtr(new StarFileHandler(path)); StarFormatter* ttic2 = new StarFormatter; ttic2->logIndex(false); ttic2->autoNewLine(false); FormatterPtr ttic2Ptr(ttic2); tasHandler->setFormatter(ttic2Ptr); Logger::getInstance(name).addHandler(tasHandler); Logger::getInstance(name).setLevel(LogLevel::DBG); }
void loadLoggerConfig() { // set the syslog handler TTICFormatter* ttic = new TTICFormatter; ttic->logIndex(false); FormatterPtr tticPtr(ttic); LogHandlerPtr syshandler = LogHandlerPtr(new StarFileHandler("./log/sys.log")); LogHandlerPtr consolehandler = LogHandlerPtr(new StarFileHandler("./log/console.log")); syshandler->setFormatter(tticPtr); consolehandler->setFormatter(tticPtr); Logger& syslog = Logger::getInstance(LOGGER_STARTUP_SYS); syslog.addHandler(syshandler); Logger::getInstance(LOGGER_STARTUP_CONSOLE).addHandler(consolehandler); /// for MTL LogHandlerPtr mtlhandler = LogHandlerPtr(new StarFileHandler("./log/mtl.log")); StarFormatter* ttic2 = new StarFormatter; ttic2->logIndex(true); FormatterPtr ttic2Ptr(ttic2); mtlhandler->setFormatter(ttic2Ptr); // for MTL dispatcher Logger::getInstance(LOGGER_MTL_DISPATCHER).addHandler(mtlhandler); Logger::getInstance(LOGGER_MTL_SKELETON).addHandler(mtlhandler); Logger::getInstance(LOGGER_MTL_PEERS).addHandler(mtlhandler); // for TIMER #ifdef _DEBUG Logger::getInstance(LOGGER_MTL_TIMER).setLevel(LogLevel::DBG); #else Logger::getInstance(LOGGER_MTL_TIMER).setLevel(LogLevel::INFO); #endif // for SOCKET LogHandlerPtr sockethandler = LogHandlerPtr(new StarFileHandler("./log/mtl-stk.log")); StarFormatter* ttic3 = new StarFormatter; ttic3->logIndex(true); FormatterPtr ttic3Ptr(ttic3); sockethandler->setFormatter(ttic3Ptr); Logger::getInstance(LOGGER_SOCKET_CLIENT).addHandler(sockethandler); Logger::getInstance(LOGGER_SOCKET_SERVER).addHandler(sockethandler); #ifdef _DEBUG Logger::getInstance(LOGGER_SOCKET_CLIENT).setLevel(LogLevel::DBG); Logger::getInstance(LOGGER_SOCKET_SERVER).setLevel(LogLevel::DBG); #else Logger::getInstance(LOGGER_SOCKET_CLIENT).setLevel(LogLevel::WARN); Logger::getInstance(LOGGER_SOCKET_SERVER).setLevel(LogLevel::WARN); #endif // for ALARM socket LogHandlerPtr alarmhandler = LogHandlerPtr(new StarFileHandler("./log/alarm-stk.log")); alarmhandler->setFormatter(FormatterPtr(new StarFormatter)); Logger::getInstance(LOGGER_SOCKET_ALARM).addHandler(alarmhandler); #ifdef _DEBUG Logger::getInstance(LOGGER_SOCKET_ALARM).setLevel(LogLevel::DBG); #else Logger::getInstance(LOGGER_SOCKET_ALARM).setLevel(LogLevel::WARN); #endif Logger::getInstance(LOGGER_STARTUP_SYS).addHandler(LogHandlerPtr(new ConsoleHandler())); Logger::getInstance(LOGGER_STARTUP_CONSOLE).addHandler(LogHandlerPtr(new ConsoleHandler())); }