Added support for loading .cfg files with logging configuration
This commit is contained in:
parent
c48c5dc34f
commit
0498acd07a
4 changed files with 19 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Add table
Reference in a new issue