当前位置: 首页>>代码示例>>C++>>正文


C++ Appender类代码示例

本文整理汇总了C++中Appender的典型用法代码示例。如果您正苦于以下问题:C++ Appender类的具体用法?C++ Appender怎么用?C++ Appender使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Appender类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: snprintf

Appender * NetAppender::getAppender(com_device_t &dev)
{
    char name[1024];
    snprintf(name, sizeof(name), "NET:%s/%s", dev.host, dev.file);
    Appender *app = (Appender *)comlog_get_nameMg()->get(type_appender, name);
    if (app == NULL) {
        _com_debug("create net appender %s", name);
        app = new NetAppender;
        app->setDeviceInfo(dev);
        _com_debug("try to open the netappender[%s]", name);
        if (app->open(NULL) != 0) {
            _com_error("sorry failt to open %s", name);
            delete app;
            return NULL;
        }
        com_device_t dev2;
        if (deviceNetToFile(dev, dev2) == 0) {
            app->_bkappender = FileAppender::getAppender(dev2);
            //assert (app->_bkappender);
            //
            if (app->_bkappender != NULL) {
                app->_bkappender->setLayout(dev2.layout);
                app->_bkappender->_open = dev2.open;
            }
        }
        comlog_get_nameMg()->set(name, app);
    }
    return app;
}
开发者ID:zz198808,项目名称:Asenal,代码行数:29,代码来源:netappender.cpp

示例2: redirectLog

int CommInpCfg :: redirectLog ()
{
    time_t      curr_t;
    struct tm  *ptm;
    char        log_file_name[32];

    time (&curr_t);
    ptm = gmtime (&curr_t);
    strftime (log_file_name, 32, "%Y%m%d_%H%M%S.log", ptm);

    string AppLogFile(dataOpt__.WorkingPath);
    AppLogFile.append("/")
    .append(log_file_name);

    Category& rootLogCategory = Category::getRoot();
    rootLogCategory.removeAllAppenders();

    Appender* appender = new FileAppender("Log", AppLogFile);
    PatternLayout* patternLayout = new PatternLayout();
    patternLayout->setConversionPattern("[%d{%Y:%m:%d %H:%M:%S.%I}] %p %c %x: %m%n");
    Layout* layout = dynamic_cast<Layout*> (patternLayout);
    appender->setLayout(layout);

    cout << "Redirecting logging from stdout to : " << AppLogFile << endl;
    rootLogCategory.addAppender(appender);

    return 0;
}
开发者ID:sutanay,项目名称:PbCdlComm,代码行数:28,代码来源:init_comm.cpp

示例3: LogLevel

bool Log::SetLogLevel(std::string const& name, const char* newLevelc, bool isLogger /* = true */)
{
    LogLevel newLevel = LogLevel(atoi(newLevelc));
    if (newLevel < 0)
        return false;

    if (isLogger)
    {
        LoggerMap::iterator it = loggers.begin();
        while (it != loggers.end() && it->second.getName() != name)
            ++it;

        if (it == loggers.end())
            return false;

        it->second.setLogLevel(newLevel);

        if (newLevel != LOG_LEVEL_DISABLED && newLevel < lowestLogLevel)
            lowestLogLevel = newLevel;
    }
    else
    {
        Appender* appender = GetAppenderByName(name);
        if (!appender)
            return false;

        appender->setLogLevel(newLevel);
    }

    return true;
}
开发者ID:piaoasd123,项目名称:ServerTest,代码行数:31,代码来源:Log.cpp

示例4: return

Appender * AppenderManager::getNextAppender()
{
    int s = m_appenders.size();
    if ( s == 1 )
        return (*m_appenders.begin());
    if ( s == 0 )
        return NULL;
    int n = m_curAppender++;
    int m = -1;
    Appender * p = NULL;
    while( n != m_curAppender )
    {
        if ( n >= s )
            n = 0;
        p = m_appenders[n];
        if (!p->isFail() )
        {
            if ( !p->isFull() )
            {
                m_curAppender = n;
                return p;
            }
            if ( m == -1 )
                m = n;
            m = n;
        }
        ++n;
    }
    m_curAppender = m;
    return m_appenders[m];
}
开发者ID:DSpeichert,项目名称:OpenLiteSpeed,代码行数:31,代码来源:appendermanager.cpp

示例5: RollFileAppender

Logger& Logger::get_instance( const std::string& filename, Level::LogLevel level, long size, int index  )
{
	if ( !logger )
	{
		Appender* appender = new RollFileAppender(filename.c_str(), size, index);
		Filter* filter = new LevelFilter( level );
		appender->tie_filter( filter );
		logger = new Logger();
		logger->add_appender( appender );
	}
	return *logger;
}
开发者ID:justinzhu,项目名称:logger,代码行数:12,代码来源:logger.cpp

示例6: tokens

void Log::CreateAppenderFromConfig(std::string const& appenderName)
{
    if (appenderName.empty())
        return;

    // Format=type, level, flags, optional1, optional2
    // if type = File. optional1 = file and option2 = mode
    // if type = Console. optional1 = Color
    std::string options = sConfigMgr->GetStringDefault(appenderName.c_str(), "");

    Tokenizer tokens(options, ',');
    Tokenizer::const_iterator iter = tokens.begin();

    size_t size = tokens.size();
    std::string name = appenderName.substr(9);

    if (size < 2)
    {
        fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong configuration for appender %s. Config line: %s\n", name.c_str(), options.c_str());
        return;
    }

    AppenderFlags flags = APPENDER_FLAGS_NONE;
    AppenderType type = AppenderType(atoi(*iter++));
    LogLevel level = LogLevel(atoi(*iter++));

    if (level > LOG_LEVEL_FATAL)
    {
        fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong Log Level %d for appender %s\n", level, name.c_str());
        return;
    }

    if (size > 2)
        flags = AppenderFlags(atoi(*iter++));

    auto factoryFunction = appenderFactory.find(type);
    if (factoryFunction == appenderFactory.end())
    {
        fprintf(stderr, "Log::CreateAppenderFromConfig: Unknown type %d for appender %s\n", type, name.c_str());
        return;
    }

    try
    {
        Appender* appender = factoryFunction->second(NextAppenderId(), name, level, flags, ExtraAppenderArgs(iter, tokens.end()));
        appenders[appender->getId()] = appender;
    }
    catch (InvalidAppenderArgsException const& iaae)
    {
        fprintf(stderr, "%s", iaae.what());
    }
}
开发者ID:piaoasd123,项目名称:ServerTest,代码行数:52,代码来源:Log.cpp

示例7: new

void HttpLog::init()
{

    s_pLogger = Logger::getRootLogger() ;
    new(achAccessLog) AccessLog("");
    Appender *appender
        = Appender::getAppender("stderr", "appender.ps");
    Layout *layout = Layout::getLayout(ERROR_LOG_PATTERN, "layout.pattern");
    layout->setUData(s_logPattern);
    appender->setLayout(layout);
    logger()->setLevel(Level::DEBUG);
    logger()->setAppender(appender);
}
开发者ID:kopytov,项目名称:openlitespeed,代码行数:13,代码来源:httplog.cpp

示例8: initLog4Qt

void initLog4Qt(Level level) {

    Log4Qt::Layout* layout;
    Appender* appender = LogManager::rootLogger()->appender("A1");
    if (appender) {
        logger()->debug("initLogQt: using existing appender A1");
        if (level != Level::INFO_INT) {
            LogManager::rootLogger()->setLevel(level);
        }
        layout = appender->layout();
    } else {
        LogManager::rootLogger()->setLevel(level);

        // Create console layout
        TTCCLayout* tccLayout = new TTCCLayout();
        tccLayout->setName("Layout");
        tccLayout->setDateFormat(TTCCLayout::ABSOLUTEDATE);
        tccLayout->setThreadPrinting(false);
        tccLayout->activateOptions();

        // Create appender A1 for console if level set through cmd line option
        if (level != Level::INFO_INT) {
            ConsoleAppender* a = new ConsoleAppender(tccLayout,
                ConsoleAppender::STDERR_TARGET);
            a->setName("A1");
            a->activateOptions();

            // Set appender on root logger
            LogManager::rootLogger()->addAppender(a);
        }

        layout = tccLayout;
    }

    // Let Log4Qt handle qDebug(), qWarning(), qCritical() and qFatal()
    LogManager::setHandleQtMessages(true);
    LogManager::qtLogger()->setLevel(Logger::rootLogger()->level());

    // Create appender A2 for log window
    Gui::TLogWindow::appender = new Gui::TLogWindowAppender(layout);
    Gui::TLogWindow::appender->setName("A2");
    Gui::TLogWindow::appender->activateOptions();

    // Set log window appender on root logger
    LogManager::rootLogger()->addAppender(Gui::TLogWindow::appender);

    logger()->info("initLog4Qt: root logger initialized on level %1",
                   LogManager::rootLogger()->level().toString());
}
开发者ID:wilbert2000,项目名称:wzplayer,代码行数:49,代码来源:main.cpp

示例9: initLogger

static log4cxx::Logger* initLogger(const char* logFile, const char* logLevel)
{
    static char s_parttern[] = "%d [%p] [%c] %m";
    using namespace LOG4CXX_NS;    
    Logger *pLogger = Logger::getRootLogger() ;
    Appender * appender
    = Appender::getAppender( logFile, "appender.ps" );
    Layout* layout = Layout::getLayout( "patternErrLog", "layout.pattern" );
    layout->setUData( s_parttern );
    appender->setLayout( layout );
    log4cxx::Level::setDefaultLevel(Level::toInt(logLevel));
    pLogger->setLevel( logLevel );
    pLogger->setAppender( appender );
    return pLogger;
}
开发者ID:wesavetheworld,项目名称:lsmcd,代码行数:15,代码来源:lcreplconf.cpp

示例10: CommInpCfg

CommInpCfg :: CommInpCfg()
{
    // Set up logging with stdout as destination
    Category& rootLogCategory = Category::getRoot();
    rootLogCategory.setPriority(Priority::INFO);
    rootLogCategory.removeAllAppenders();

    Appender* appender = new FileAppender("_", dup(fileno(stdout)));
    PatternLayout* patternLayout = new PatternLayout();
    patternLayout->setConversionPattern("[%d{%Y:%m:%d %H:%M:%S.%I}] %p %c %x: %m%n");
    Layout* layout = dynamic_cast<Layout*> (patternLayout);
    appender->setLayout(layout);

    rootLogCategory.addAppender(appender);
}
开发者ID:sutanay,项目名称:PbCdlComm,代码行数:15,代码来源:init_comm.cpp

示例11: writeArray

		void Writer::writeArray(Appender& appender, const Value& value, Size indent)
		{
			appender.append("[" + lineBreak());
			for (Size i = 0; i < value.getLength(); i++)
			{
				appender.append(space(indent + 1));
				write(appender, value.get(i), indent + 1);
				if (i + 1 != value.getLength())
				{
					appender.append(",");
				}
				appender.append(lineBreak());
			}
			appender.append(space(indent) + "]");
		}
开发者ID:marcellus-trixus,项目名称:duel6r,代码行数:15,代码来源:JsonWriter.cpp

示例12: locker

void MainThreadAppender::append(const LoggingEvent &rEvent)
{
    QReadLocker locker(&mAppenderGuard);

    Appender *pAppender;
    Q_FOREACH(pAppender, mAppenders)
    {
        if (QThread::currentThread() != qApp->thread())
        {
            LoggingEvent *event = new LoggingEvent(rEvent);
            qApp->postEvent(pAppender, event);

        }
        else
            pAppender->doAppend(rEvent);
    }
}
开发者ID:DenisVerkhovsky,项目名称:Log4Qt,代码行数:17,代码来源:mainthreadappender.cpp

示例13: lock

bool Logger::readLog(std::string &target) {
	bool success = false;
	LockGuard lock(m_mutex);
	for (size_t i=0; i<m_appenders.size(); ++i) {
		Appender *appender = m_appenders[i];
		if (appender->getClass()->derivesFrom(MTS_CLASS(StreamAppender))) {
			StreamAppender *streamAppender =
				static_cast<StreamAppender *>(appender);
			if (streamAppender->logsToFile()) {
				streamAppender->readLog(target);
				success = true;
				break;
			}
		}
	}
	return success;
}
开发者ID:winmad,项目名称:mitsuba,代码行数:17,代码来源:logger.cpp

示例14: writeObject

		void Writer::writeObject(Appender& appender, const Value& value, Size indent)
		{
			appender.append("{" + lineBreak());
			auto propNames = value.getPropertyNames();
			for (Size i = 0; i < propNames.size(); i++)
			{
				const std::string& name = propNames[i];
				appender.append(space(indent + 1) + '"' + name + "\": ");
				write(appender, value.get(name), indent + 1);
				if (i + 1 != propNames.size())
				{
					appender.append(",");
				}
				appender.append(lineBreak());
			}
			appender.append(space(indent) + "}");
		}
开发者ID:marcellus-trixus,项目名称:duel6r,代码行数:17,代码来源:JsonWriter.cpp

示例15: logger

int HttpLog::setErrorLogFile(const char *pFileName)
{
    Appender *appender
        = Appender::getAppender(pFileName, "appender.ps");
    if (appender)
    {
        Appender *pOld = logger()->getAppender();
        if ((pOld) && (pOld != appender))
            pOld->close();
        Layout *layout = Layout::getLayout(ERROR_LOG_PATTERN, "layout.pattern");
        appender->setLayout(layout);
        logger()->setAppender(appender);
        return 0;
    }
    else
        return LS_FAIL;
}
开发者ID:kopytov,项目名称:openlitespeed,代码行数:17,代码来源:httplog.cpp


注:本文中的Appender类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。