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
 
@@ -12,10 +12,15 @@ users_per_backend=2
 
backend=../../backends/libpurple/spectrum_libpurple_backend
 
#backend=../../backends/libircclient-qt/spectrum_libircclient-qt_backend
 
#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
 
#config=test.cfg
 

	
 
[database]
 
type = sqlite3 # or "none" without database backend
 
database = test.sql
 
prefix=icq
spectrum/src/sample2.cfg
Show inline comments
 
@@ -12,10 +12,14 @@ users_per_backend=2
 
backend=spectrum_libpurple_backend
 
#backend=spectrum_libircclient-qt_backend
 
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
 
#prefix=icq
src/config.cpp
Show inline comments
 
@@ -50,12 +50,14 @@ bool Config::load(const std::string &configfile, boost::program_options::options
 
		("registration.username_field", value<std::string>()->default_value(""), "Label for username field")
 
		("registration.username_mask", value<std::string>()->default_value(""), "Username mask")
 
		("registration.encoding", value<std::string>()->default_value("en"), "Default encoding in registration form")
 
		("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);
 
	notify(m_variables);
 

	
 
	m_file = configfile;
src/transport.cpp
Show inline comments
 
@@ -28,12 +28,13 @@
 
#include "Swiften/TLS/OpenSSL/OpenSSLServerContext.h"
 
#include "Swiften/TLS/PKCS12Certificate.h"
 
#include "Swiften/TLS/OpenSSL/OpenSSLServerContextFactory.h"
 
#include "log4cxx/logger.h"
 
#include "log4cxx/consoleappender.h"
 
#include "log4cxx/patternlayout.h"
 
#include "log4cxx/propertyconfigurator.h"
 

	
 
using namespace Swift;
 
using namespace boost;
 
using namespace log4cxx;
 

	
 
namespace Transport {
 
@@ -65,16 +66,19 @@ Component::Component(Swift::EventLoop *loop, Config *config, Factory *factory) {
 
	m_server = NULL;
 
	m_reconnectCount = 0;
 
	m_config = config;
 
	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"));
 

	
 
	m_factories = new BoostNetworkFactories(loop);
 

	
0 comments (0 inline, 0 general)