Ejemplo n.º 1
0
 void getLoggingMethods(FB::Log::LogMethodList& outMethods) {
   // The next line will enable logging to the console (think: printf).
   outMethods.push_back(
       std::make_pair(FB::Log::LogMethod_Console, std::string()));
   // The next line will enable logging to a logfile.
   outMethods.push_back(
       std::make_pair(FB::Log::LogMethod_File, "/Users/xzhang/cmpt/chrome/log"));
   // Obviously, if you use both lines, you will get output on both sinks.
 }
Ejemplo n.º 2
0
void FB::Log::initLogging()
{
    if (logging_started)
        return;

    bool addedAppender = false;

    log4cplus::Logger logger = log4cplus::Logger::getInstance(L"FireBreath");

    FB::Log::LogLevel ll = getFactoryInstance()->getLogLevel();
    logger.setLogLevel(translate_logLevel(ll));

    FB::Log::LogMethodList mlist;
    getFactoryInstance()->getLoggingMethods(mlist);

    for (FB::Log::LogMethodList::const_iterator it = mlist.begin(); it != mlist.end(); ++it) {
        switch( it->first ) {
        case FB::Log::LogMethod_Console: {
#ifdef FB_WIN
            log4cplus::SharedAppenderPtr debugAppender(new log4cplus::Win32DebugAppender());
            std::auto_ptr<log4cplus::Layout> layout2(new log4cplus::TTCCLayout());
            debugAppender->setLayout(layout2);
            logger.addAppender(debugAppender);
            addedAppender = true;
#else
            log4cplus::SharedAppenderPtr debugAppender(new log4cplus::ConsoleAppender());
            std::auto_ptr<log4cplus::Layout> layout2(new log4cplus::TTCCLayout());
            debugAppender->setLayout(layout2);
            logger.addAppender(debugAppender);
            addedAppender = true;
#endif
            } break;
        case FB::Log::LogMethod_File: {
            log4cplus::SharedAppenderPtr fileAppender(new log4cplus::FileAppender(FB::utf8_to_wstring(it->second)));
            std::auto_ptr<log4cplus::Layout> layout(new log4cplus::TTCCLayout());
            fileAppender->setLayout(layout);
            logger.addAppender(fileAppender);
            addedAppender = true;
          }
        }
    }

    // If there are no other appenders, add a NULL appender
    if (!addedAppender) {
        log4cplus::SharedAppenderPtr nullAppender(new log4cplus::NullAppender());
        std::auto_ptr<log4cplus::Layout> layout3(new log4cplus::TTCCLayout());
        nullAppender->setLayout(layout3);
        logger.addAppender(nullAppender);
    }
    
    logging_started = true;
}
Ejemplo n.º 3
0
 // Set FireBreath's log methods
 void getLoggingMethods(FB::Log::LogMethodList& outMethods)
 {
     outMethods.push_back(std::make_pair(FB::Log::LogMethod_Console, std::string()));
 }
Ejemplo n.º 4
0
void FB::FactoryBase::getLoggingMethods( FB::Log::LogMethodList& outMethods )
{
#ifndef NDEBUG
    outMethods.push_back(std::make_pair(FB::Log::LogMethod_Console, std::string()));
#endif
}
Ejemplo n.º 5
0
 void getLoggingMethods( FB::Log::LogMethodList& outMethods )
 {
     outMethods.push_back(std::make_pair(FB::Log::LogMethod_File, "/tmp/trezor.log"));
 }