コード例 #1
0
ファイル: rrLogger.cpp プロジェクト: Peter-J/roadrunner
void Logger::enableFileLogging(const std::string& fileName, int level)
{
    Mutex::ScopedLock lock(loggerMutex);

    Logger::setLevel(level);

    // close the current file log and re-create it.
    disableFileLogging();

    if (!simpleFileChannel)
    {
        std::string realName;

        // figure out what file name to use
        if (fileName.length() == 0) {
            // none given, use one from config.
            realName = Config::getString(Config::LOGGER_LOG_FILE_PATH);
        } else {
            realName = fileName;
        }

        if (realName.length() == 0) {
            // default log name.
            realName = joinPath(getTempDir(), "roadrunner.log");
        } else {
            // expand any env vars and make absolute path.
            realName = Poco::Path::expand(realName);
            Poco::Path path(realName);
            realName = path.makeAbsolute().toString();
        }

        // check if the path is writable
        Poco::Path p(realName);
        Poco::File fdir = p.parent();
        if(!fdir.exists())
        {
            realName = joinPath(getTempDir(), "roadrunner.log");
            Log(Logger::LOG_ERROR) << "The specified log file directory path, "
                    << fdir.path() << " does not exist, using default log file path: "
                    << realName;
        }

        SplitterChannel *splitter = getSplitterChannel();

        simpleFileChannel = new SimpleFileChannel();
        simpleFileChannel->setProperty("path", realName);
        simpleFileChannel->setProperty("rotation", "never");

        logFileName = simpleFileChannel->getProperty("path");

        splitter->addChannel(simpleFileChannel);
        simpleFileChannel->release();
    }
}
コード例 #2
0
ファイル: rrLogger.cpp プロジェクト: Peter-J/roadrunner
void Logger::enableConsoleLogging(int level)
{
    Mutex::ScopedLock lock(loggerMutex);

    Logger::setLevel(level);

    if (!consoleChannel)
    {
        SplitterChannel *splitter = getSplitterChannel();

        // default is console channel
        consoleChannel = createConsoleChannel();

        // let the logger manage ownership of the channels, we keep then around
        // so we can know when to add or remove them.
        splitter->addChannel(consoleChannel);

        consoleChannel->release();
    }
}
コード例 #3
0
ファイル: rrLogger.cpp プロジェクト: 0u812/roadrunner-backup
void Logger::enableFileLogging(const std::string& fileName, int level)
{
    Mutex::ScopedLock lock(loggerMutex);

    Logger::setLevel(level);

    if (!simpleFileChannel)
    {
        SplitterChannel *splitter = getSplitterChannel();

        simpleFileChannel = new SimpleFileChannel();
        simpleFileChannel->setProperty("path", fileName);
        simpleFileChannel->setProperty("rotation", "never");

        logFileName = simpleFileChannel->getProperty("path");

        splitter->addChannel(simpleFileChannel);
        simpleFileChannel->release();
    }
}