Exemplo n.º 1
0
// Create and configure the Output objects.
void Manager::configure(const Config::Vector& aConfigList) {
    // List of all Output class ; those names are in the form
    // - "class Log::OutputConsole" under Visual Studio 2010
    // - "N3Log13OutputConsoleE" under GCC
    std::string outputConsole = typeid(OutputConsole).name();
    std::string outputFile    = typeid(OutputFile).name();
#ifdef WIN32
    std::string outputDebug   = typeid(OutputDebug).name();
#endif

    Config::Vector::const_iterator  iConfig;
    for (  iConfig  = aConfigList.begin();
           iConfig != aConfigList.end();
         ++iConfig) {
        Output::Ptr         outputPtr;
        const std::string&  configName = (*iConfig)->getName();

        // Compare the provided Output name with the known class name
        if (std::string::npos != outputConsole.find(configName)) {
            outputPtr.reset(new OutputConsole((*iConfig)));
        } else if (std::string::npos != outputFile.find(configName)) {
            outputPtr.reset(new OutputFile((*iConfig)));
#ifdef WIN32
        } else if (std::string::npos != outputDebug.find(configName)) {
            outputPtr.reset(new OutputDebug((*iConfig)));
#endif
        } else {
            LOGGER_THROW("Unknown Output name '" << configName << "'");
        }
        mOutputList.push_back(outputPtr);
    }
}
Exemplo n.º 2
0
// Open the file
void OutputFile::open() const {
    mpFile = fopen(mFilename.c_str(), "ab");
    if (nullptr == mpFile) {
        LOGGER_THROW("file \"" << mFilename << "\" not opened");
    }
}