Redirect stderr in separate method
This commit is contained in:
parent
8b60685886
commit
c290016c8e
3 changed files with 14 additions and 6 deletions
|
@ -57,6 +57,7 @@ namespace Logging {
|
|||
void initBackendLogging(Config *config);
|
||||
void initMainLogging(Config *config);
|
||||
void shutdownLogging();
|
||||
void redirect_stderr();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue