Changeset - 18410fbf8572
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2016-02-08 15:18:03
jkaluza@redhat.com
Libtransport: Make the error message more verbose when we are not able to load [logging] files
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
libtransport/Logging.cpp
Show inline comments
 
@@ -91,51 +91,53 @@ static intercept_stream* intercepter_cout;
 
static intercept_stream* intercepter_cerr;
 

	
 

	
 
static void initLogging(Config *config, std::string key, bool only_create_dir = false) {
 
	if (CONFIG_STRING(config, key).empty()) {
 
		if (only_create_dir) {
 
			return;
 
		}
 
		root = log4cxx::Logger::getRootLogger();
 
#ifdef _MSC_VER
 
		root->addAppender(new ConsoleAppender(new PatternLayout(L"%d %-5p %c: %m%n")));
 
#else
 
		root->addAppender(new ConsoleAppender(new PatternLayout("%d %-5p %c: %m%n")));
 
#endif
 
	}
 
	else {
 
		log4cxx::helpers::Properties p;
 

	
 
		log4cxx::helpers::FileInputStream *istream = NULL;
 
		try {
 
			istream = new log4cxx::helpers::FileInputStream(CONFIG_STRING(config, key));
 
		}
 
		catch(log4cxx::helpers::IOException &ex) {
 
			std::cerr << "Can't create FileInputStream logger instance: " << ex.what() << "\n";
 
			std::cerr << "This is usually caused by the non-existing \"" << CONFIG_STRING(config, key) << "\" file or bad permissions.\n";
 
		}
 
		catch (...) {
 
			std::cerr << "Can't create FileInputStream logger instance\n";
 
			std::cerr << "This is usually caused by the non-existing \"" << CONFIG_STRING(config, key) << "\" file or bad permissions.\n";
 
		}
 

	
 
		if (!istream) {
 
			return;
 
		}
 

	
 
		p.load(istream);
 
		LogString pid, jid, id;
 
		log4cxx::helpers::Transcoder::decode(boost::lexical_cast<std::string>(getpid()), pid);
 
		log4cxx::helpers::Transcoder::decode(CONFIG_STRING(config, "service.jid"), jid);
 
		log4cxx::helpers::Transcoder::decode(CONFIG_STRING_DEFAULTED(config, "service.backend_id", ""), id);
 
#ifdef _MSC_VER
 
		p.setProperty(L"pid", pid);
 
		p.setProperty(L"jid", jid);
 
		p.setProperty(L"id", id);
 
#else
 
		p.setProperty("pid", pid);
 
		p.setProperty("jid", jid);
 
		p.setProperty("id", id);
 
#endif
 

	
 
		std::vector<std::string> dirs;
 
		BOOST_FOREACH(const log4cxx::LogString &prop, p.propertyNames()) {
 
			if (boost::ends_with(prop, ".File")) {
0 comments (0 inline, 0 general)