2
// C++ Implementation: ConfigBoundLogObserver
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2007
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
27
#include "ConfigBoundLogObserver.h"
29
#include "framework/LoggingInstance.h"
30
#include "services/config/ConfigService.h"
34
ConfigBoundLogObserver::ConfigBoundLogObserver(std::ostream &out)
35
: Ember::StreamLogObserver(out)
37
Ember::EmberServices::getSingletonPtr()->getConfigService()->EventChangedConfigItem.connect(sigc::mem_fun(*this, &ConfigBoundLogObserver::ConfigService_EventChangedConfigItem));
43
ConfigBoundLogObserver::~ConfigBoundLogObserver()
48
* Updates from the config. The relevant section is "general" and the key "logginglevel". It can have the values of verbose|info|warning|failure|critical
50
void ConfigBoundLogObserver::updateFromConfig()
52
if (Ember::EmberServices::getSingletonPtr()->getConfigService()->itemExists("general", "logginglevel")) {
53
std::string loggingLevel = static_cast<std::string>(Ember::EmberServices::getSingletonPtr()->getConfigService()->getValue("general", "logginglevel"));
54
Ember::Log::MessageImportance importance(Ember::Log::INFO);
55
if (loggingLevel == "verbose") {
56
importance = Ember::Log::VERBOSE;
57
} else if (loggingLevel == "info") {
58
importance = Ember::Log::INFO;
59
} else if (loggingLevel == "warning") {
60
importance = Ember::Log::WARNING;
61
} else if (loggingLevel == "failure") {
62
importance = Ember::Log::FAILURE;
63
} else if (loggingLevel == "critical") {
64
importance = Ember::Log::CRITICAL;
66
setFilter(importance);
72
* React on changes to the config.
76
void ConfigBoundLogObserver::ConfigService_EventChangedConfigItem(const std::string& section, const std::string& key)
78
if (section == "general") {
79
if (key == "logginglevel") {