AppLogger::AppLogger()
{
	AutoPtr<SimpleFileChannel> pChannel(new SimpleFileChannel);
	pChannel->setProperty("path", "CommLogs.log");
	pChannel->setProperty("rotation", "never");
	Logger::root().setChannel(pChannel);
}
Channel* LoggingConfigurator::createChannel(AbstractConfiguration* pConfig)
{
    AutoPtr<Channel> pChannel(LoggingFactory::defaultFactory().createChannel(pConfig->getString("class")));
    AutoPtr<Channel> pWrapper(pChannel);
    AbstractConfiguration::Keys props;
    pConfig->keys(props);
    for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
    {
        if (*it == "pattern")
        {
            AutoPtr<Formatter> pPatternFormatter(new PatternFormatter(pConfig->getString(*it)));
            pWrapper = new FormattingChannel(pPatternFormatter, pChannel);
        }
        else if (*it == "formatter")
        {
            AutoPtr<FormattingChannel> pFormattingChannel(new FormattingChannel(0, pChannel));
            if (pConfig->hasProperty("formatter.class"))
            {
                AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it));
                AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
                pFormattingChannel->setFormatter(pFormatter);
            }
            else pFormattingChannel->setProperty(*it, pConfig->getString(*it));
#if defined(__GNUC__) && __GNUC__ < 3
            pWrapper = pFormattingChannel.duplicate();
#else
            pWrapper = pFormattingChannel;
#endif
        }
    }
    return pWrapper.duplicate();
}
示例#3
0
//-------------------------------------------------------------------------------------
void ClientObject::gameTick()
{
	if(pChannel()->endpoint())
	{
		pChannel()->handleMessage(NULL);
		sendTick();
	}

	switch(state_)
	{
		case C_STATE_INIT:

			state_ = C_STATE_PLAY;

			if(!initCreate() || !createAccount())
				return;

			break;
		case C_STATE_LOGIN:

			state_ = C_STATE_PLAY;

			if(!login())
				return;

			break;
		case C_STATE_LOGIN_GATEWAY:

			state_ = C_STATE_PLAY;

			if(!initLoginGateWay() || !loginGateWay())
				return;

			break;
		case C_STATE_PLAY:
			break;
		default:
			KBE_ASSERT(false);
			break;
	};
}
示例#4
0
void Plugin::setupLogger()
{
    AutoPtr<FileChannel>            pChannel(new FileChannel);
    AutoPtr<ConsoleChannel>         cConsole(new ConsoleChannel);
    AutoPtr<SplitterChannel>        pSplitter(new SplitterChannel);
    AutoPtr<PatternFormatter>       pFormatter(new PatternFormatter);
    pFormatter->setProperty("pattern", "%Y-%m-%d %H:%M:%S [%p]: %t");
    pFormatter->setProperty("times", "local");
    // We will uncomment this later. Maybe. This preventing from writing into log files
    //pSplitter->addChannel(pChannel);
    pSplitter->addChannel(cConsole);
    //pChannel->setProperty("path", "/var/log/git-keshig.log");
    //pChannel->setProperty("rotation", "5 M");
    AutoPtr<FormattingChannel> pFormatChannel(new FormattingChannel(pFormatter, pSplitter));
    Logger& log = Application::instance().logger();
    log.setLevel(Poco::Message::PRIO_DEBUG);
    log.setChannel(pFormatChannel);
}
示例#5
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
ChannelModel::pFutureChannel_type 
ChannelModel::createChannel(Common::I_Session& _session, const std::string& _name, const std::string& _description)
{
    /// TODO Check session (i.e. session user) against permissions.

    /// TODO Make this async
    pFutureChannel_type returnValue(new FutureChannel_type);

    // Get the data map.
    Community::Chat::I_ChatChannelDataMap::pChatChannelDataMap_type pChannelDM =
        Community::Chat::I_ChatChannelDataMap::create(
            m_service.getApplicationServer().getDatabaseConnection(
                m_service.getDatabaseConnectionName()
            )
        );

    // Create a new domain object.
    Community::Chat::I_ChatChannelDataMap::pChatChannelDomainObject_type pChannelDO =
        pChannelDM->createNew();

    // Populate the values.
    pChannelDO->getName()           = _name;
    pChannelDO->getDescription()    = _description;

    // Update the object (and in this case, insert it).
    boost::uint64_t newChannelId    = pChannelDM->update(pChannelDO)->getValue();
    pChannelDO->getChatChannelId()  = newChannelId;

    Channel* pRawChannel = new Channel(m_service, pChannelDO);

    pChannel_type pChannel(
        pRawChannel,
        &destroyChannel
    );

    m_channels[_name] = pChannel;

    onAddChannel(pChannel);

    returnValue->setValue(pChannel);

    return returnValue;
}
void LoggingConfigurator::configureLogger(AbstractConfiguration* pConfig)
{
    Logger& logger = Logger::get(pConfig->getString("name", ""));
    AbstractConfiguration::Keys props;
    pConfig->keys(props);
    for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
    {
        if (*it == "channel" && pConfig->hasProperty("channel.class"))
        {
            AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
            AutoPtr<Channel> pChannel(createChannel(pChannelConfig));
            configureChannel(pChannel, pChannelConfig);
            Logger::setChannel(logger.name(), pChannel);
        }
        else if (*it != "name")
        {
            Logger::setProperty(logger.name(), *it, pConfig->getString(*it));
        }
    }
}
示例#7
0
void NodeLogger::init(const std::string &filePath, const std::string &name) {
    // file channel:
    Poco::AutoPtr<Poco::FileChannel> pChannel(new Poco::FileChannel);
    pChannel->setProperty("path", filePath);
    pChannel->setProperty("rotation", "10 M");
    pChannel->setProperty("archive", "timestamp");
    pChannel->setProperty("compress", "true");
    pChannel->setProperty("purgeAge", "7 days");

    // formatter:
    Poco::AutoPtr<Poco::PatternFormatter> pFrmt(new Poco::PatternFormatter);
    pFrmt->setProperty("pattern", "%Y-%m-%d %H:%M:%S [%p] %s : %t");

    // formatting channel:
    Poco::AutoPtr<Poco::FormattingChannel> pFrmtC(new Poco::FormattingChannel(pFrmt, pChannel));

    Poco::Logger::root().setChannel(pFrmtC);

    Poco::Logger &log = Poco::Logger::get(name);
    log.setLevel(DEFAULT_LOG_LEVEL);
    log.debug("Logger initialized.");
}
Logger& ServerLog::getLogger(LOG_TYPE logtype) {
    switch (logtype) {
        case ACTIVITY:
        {
            AutoPtr<FileChannel> pChannel(new FileChannel);
//            pChannel->setProperty("path", "PocoLog/ActivityLog/activity.log");
            pChannel->setProperty("path", "../../../PocoLog/ActivityLog/activity.log");
            pChannel->setProperty("rotation", "200K");
            pChannel->setProperty("archive", "timestamp");
            Logger::root().setChannel(pChannel);
            Logger& logger = Logger::get("ActivityLogger"); // inherits root channel
            logger.setChannel(pChannel);
            return logger;
        }
        case SERVICE:
        {
            AutoPtr<FileChannel> pChannel(new FileChannel);
//            pChannel->setProperty("path", "PocoLog/Service/service.log");
            pChannel->setProperty("path", "../../../PocoLog/Service/service.log");
            pChannel->setProperty("rotation", "200K");
            pChannel->setProperty("archive", "timestamp");
            Logger::root().setChannel(pChannel);
            Logger& logger = Logger::get("ActivityLogger"); // inherits root channel
            logger.setChannel(pChannel);
            return logger;
        }
        case DATA_MSGID:
        {
            AutoPtr<FileChannel> pChannel(new FileChannel);
//            pChannel->setProperty("path", "PocoLog/DataLog/save_msgId.log");
            pChannel->setProperty("path", "../../../PocoLog/DataLog/save_msgId.log");
            pChannel->setProperty("rotation", "200K");
            pChannel->setProperty("archive", "timestamp");
            Logger::root().setChannel(pChannel);
            Logger& logger = Logger::get("DataLogger"); // inherits root channel
            logger.setChannel(pChannel);
            return logger;
        }
        case DATA_MSGITEM:
        {
            AutoPtr<FileChannel> pChannel(new FileChannel);
//            pChannel->setProperty("path", "PocoLog/DataLog/save_msgItem.log");
            pChannel->setProperty("path", "../../../PocoLog/DataLog/save_msgItem.log");
            pChannel->setProperty("rotation", "200K");
            pChannel->setProperty("archive", "timestamp");
            Logger::root().setChannel(pChannel);
            Logger& logger = Logger::get("DataLogger"); // inherits root channel
            logger.setChannel(pChannel);
            return logger;
        }
        case DATA_MSGOFFLINE:
        {
            AutoPtr<FileChannel> pChannel(new FileChannel);
//            pChannel->setProperty("path", "PocoLog/DataLog/save_msgOffline.log");
            pChannel->setProperty("path", "../../../PocoLog/DataLog/save_msgOffline.log");
            pChannel->setProperty("rotation", "200K");
            pChannel->setProperty("archive", "timestamp");
            Logger::root().setChannel(pChannel);
            Logger& logger = Logger::get("DataLogger"); // inherits root channel
            logger.setChannel(pChannel);
            return logger;
        }
        case WORKER_WRITEDB:
        {
            AutoPtr<FileChannel> pChannel(new FileChannel);
//            pChannel->setProperty("path", "PocoLog/WorkerLog/writeDB.log");
            pChannel->setProperty("path", "../../../PocoLog/WorkerLog/writeDB.log");
            pChannel->setProperty("rotation", "200K");
            pChannel->setProperty("archive", "timestamp");
            Logger::root().setChannel(pChannel);
            Logger& logger = Logger::get("DataLogger"); // inherits root channel
            logger.setChannel(pChannel);
            return logger;
        }
        case ERROR:
        {
            AutoPtr<FileChannel> pChannel(new FileChannel);
//            pChannel->setProperty("path", "PocoLog/ErrorLog/error.log");
            pChannel->setProperty("path", "../../../PocoLog/ErrorLog/error.log");
            pChannel->setProperty("rotation", "200K");
            pChannel->setProperty("archive", "timestamp");
            Logger::root().setChannel(pChannel);
            Logger& logger = Logger::get("ErrorLogger"); // inherits root channel
            logger.setChannel(pChannel);
            return logger;
        }
    }
}