Changeset - c290016c8e99
[Not reviewed]
0 3 0
HanzZ - 13 years ago 2012-09-12 11:49:46
hanzz.k@gmail.com
Redirect stderr in separate method
3 files changed with 14 insertions and 6 deletions:
0 comments (0 inline, 0 general)
include/transport/logging.h
Show inline comments
 
@@ -57,6 +57,7 @@ namespace Logging {
 
void initBackendLogging(Config *config);
 
void initMainLogging(Config *config);
 
void shutdownLogging();
 
void redirect_stderr();
 

	
 
}
 

	
spectrum/src/main.cpp
Show inline comments
 
@@ -315,6 +315,7 @@ int main(int argc, char **argv)
 
    }
 
#endif
 

	
 
	Logging::initMainLogging(&config);
 

	
 
#ifndef WIN32
 
	if (!CONFIG_STRING(&config, "service.group").empty() ||!CONFIG_STRING(&config, "service.user").empty() ) {
 
@@ -377,9 +378,7 @@ int main(int argc, char **argv)
 
		return -1;
 
	}
 

	
 
	// Logging has to be initialized after all std:cerr output here, because
 
	// it forwards std::cerr to log file.
 
	Logging::initMainLogging(&config);
 
	Logging::redirect_stderr();
 

	
 
	UserManager userManager(&transport, &userRegistry, storageBackend);
 
	userManager_ = &userManager;
src/logging.cpp
Show inline comments
 
@@ -166,19 +166,23 @@ static void initLogging(Config *config, std::string key) {
 

	
 
		log4cxx::PropertyConfigurator::configure(p);
 
	}
 

	
 
	 intercepter_cerr = new intercept_stream(std::cerr, "cerr");
 
	 intercepter_cout = new intercept_stream(std::cout, "cout");
 
}
 

	
 
void initBackendLogging(Config *config) {
 
	initLogging(config, "logging.backend_config");
 

	
 
	redirect_stderr();
 
}
 

	
 
void initMainLogging(Config *config) {
 
	initLogging(config, "logging.config");
 
}
 

	
 
void redirect_stderr() {
 
	 intercepter_cerr = new intercept_stream(std::cerr, "cerr");
 
	 intercepter_cout = new intercept_stream(std::cout, "cout");
 
}
 

	
 
void shutdownLogging() {
 
	delete intercepter_cerr;
 
	delete intercepter_cout;
 
@@ -194,6 +198,10 @@ void initMainLogging(Config */*config*/) {
 

	
 
void shutdownLogging() {
 
	
 
}
 

	
 
void redirect_stderr() {
 
	
 
}
 
#endif /* WITH_LOG4CXX */
 

	
0 comments (0 inline, 0 general)