/* * Module.cpp * * Copyright (C) 2009 Matthias Schiffer * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this program. If not, see . */ #include "../export.h" #include "Module.h" #include namespace Mad { namespace Modules { namespace FileLogger { void Module::configure() { std::vector entries = application->getConfigManager()->getEntries("Log"); for(std::vector::iterator entry = entries.begin(); entry != entries.end(); ++entry) { const std::vector &values = (*entry)->getValues(); if(values.size() < 2 || !values.front().matches("File")) continue; boost::shared_ptr logger(new FileLogger(values[1].toLocale())); loggers.insert(logger); application->getLogManager()->registerLogger(logger); bool remote = false; for(std::vector::const_iterator value = values.begin()+2; value != values.end(); ++value) { if(value->matches("remote")) remote = true; } Core::String level = (*entry)->get("Level"); if(!level.isEmpty()) { try { if(remote) logger->setRemoteLevel(Core::LogManager::parseLevel(level)); else logger->setLevel(Core::LogManager::parseLevel(level)); } catch(Core::Exception e) { application->logf(Core::Logger::LOG_WARNING, "Unknown log level '%s'.", level.toLocale().c_str()); } } } } } } } extern "C" { MAD_MODULE_EXPORT Mad::Common::Module* FileLogger_create(Mad::Common::Application *application) { return new Mad::Modules::FileLogger::Module(application); } }