Changeset - 0498acd07a1d
[Not reviewed]
0 4 0
Jan Kaluza - 14 years ago 2011-06-21 13:37:01
hanzz.k@gmail.com
Added support for loading .cfg files with logging configuration
4 files changed with 19 insertions and 4 deletions:
0 comments (0 inline, 0 general)
spectrum/src/sample.cfg
Show inline comments
 
@@ -15,6 +15,11 @@ backend=../../backends/libpurple/spectrum_libpurple_backend
 
protocol=prpl-msn
 
#protocol=prpl-icq
 

	
 
[logging]
 
#config=logging.cfg # log4cxx/log4j logging configuration file
 
#backend_config=backend_logging.cfg # log4cxx/log4j logging configuration file for backends
 
#config=test.cfg
 

	
 
[database]
 
type = sqlite3 # or "none" without database backend
 
database = test.sql
spectrum/src/sample2.cfg
Show inline comments
 
@@ -15,6 +15,10 @@ protocol=prpl-jabber
 
#protocol=prpl-msn
 
#protocol=prpl-icq
 

	
 
[logging]
 
#config=logging.cfg # log4cxx/log4j logging configuration file
 
#backend_config=backend_logging.cfg # log4cxx/log4j logging configuration file for backends
 

	
 
[database]
 
type = none # "sqlite3" or "none" without database backend
 
database = test.sql
src/config.cpp
Show inline comments
 
@@ -53,6 +53,8 @@ bool Config::load(const std::string &configfile, boost::program_options::options
 
		("database.type", value<std::string>()->default_value("none"), "Database type.")
 
		("database.database", value<std::string>()->default_value(""), "Database used to store data")
 
		("database.prefix", value<std::string>()->default_value(""), "Prefix of tables in database")
 
		("logging.config", value<std::string>()->default_value(""), "Path to log4cxx config file which is used for Spectrum 2 instance")
 
		("logging.backend_config", value<std::string>()->default_value(""), "Path to log4cxx config file which is used for backends")
 
	;
 

	
 
	store(parse_config_file(ifs, opts), m_variables);
src/transport.cpp
Show inline comments
 
@@ -31,6 +31,7 @@
 
#include "log4cxx/logger.h"
 
#include "log4cxx/consoleappender.h"
 
#include "log4cxx/patternlayout.h"
 
#include "log4cxx/propertyconfigurator.h"
 

	
 
using namespace Swift;
 
using namespace boost;
 
@@ -68,10 +69,13 @@ Component::Component(Swift::EventLoop *loop, Config *config, Factory *factory) {
 
	m_factory = factory;
 
	m_loop = loop;
 

	
 
// 	BasicConfigurator::configure();
 

	
 
	LoggerPtr root = Logger::getRootLogger();
 
	root->addAppender(new ConsoleAppender(new PatternLayout("%d %-5p %c: %m%n")));
 
	if (CONFIG_STRING(m_config, "logging.config").empty()) {
 
		LoggerPtr root = Logger::getRootLogger();
 
		root->addAppender(new ConsoleAppender(new PatternLayout("%d %-5p %c: %m%n")));
 
	}
 
	else {
 
		log4cxx::PropertyConfigurator::configure(CONFIG_STRING(m_config, "logging.config"));
 
	}
 

	
 

	
 
	m_jid = Swift::JID(CONFIG_STRING(m_config, "service.jid"));
0 comments (0 inline, 0 general)