From abf1495c5e6e33a93a0277ef301643e7ff2ab4dd Mon Sep 17 00:00:00 2001 From: Gerald Begumisa Date: Thu, 19 Jul 2007 09:34:07 +0000 Subject: Multiple orkaudio instances may be ran on one server by setting the environment variables ORKAUDIO_CONFIG_PATH and ORKAUDIO_LOGGING_PATH to point to the location of the configuration files and log files respectively. Two variables in config.xml and have been added which specify the ports for the command line server and HTTP server respectively - these default to 59130 and 59140 respectively, note that previously the default ports were 10000 and 20000 respectively. git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@455 09dcff7a-b715-0410-9601-b79a96267cd0 --- orkbasecxx/LogManager.cpp | 53 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'orkbasecxx/LogManager.cpp') diff --git a/orkbasecxx/LogManager.cpp b/orkbasecxx/LogManager.cpp index 2162ef9..5d83985 100644 --- a/orkbasecxx/LogManager.cpp +++ b/orkbasecxx/LogManager.cpp @@ -13,6 +13,7 @@ #define _WINSOCKAPI_ // prevents the inclusion of winsock.h +#include "ace/OS_NS_dirent.h" #include "LogManager.h" #include #include @@ -29,23 +30,51 @@ void OrkLogManager::Initialize() { BasicConfigurator::configure(); - char* logCfgFilename = ""; - FILE* file = ACE_OS::fopen("logging.properties", "r"); - if(file) - { - // logging.properties exists in the current directory - logCfgFilename = "logging.properties"; - fclose(file); - } - else - { - // logging.properties could not be found in the current directory, try to find it in system configuration directory - logCfgFilename = "/etc/orkaudio/logging.properties"; + char* logCfgFilename = ""; + char* cfgEnvPath = ""; + int cfgAlloc = 0; + + cfgEnvPath = ACE_OS::getenv("ORKAUDIO_CONFIG_PATH"); + if(cfgEnvPath) { + ACE_DIR* dir = ACE_OS::opendir(cfgEnvPath); + if(dir) { + int len = 0; + + ACE_OS::closedir(dir); + len = strlen(cfgEnvPath)+1+strlen("logging.properties")+1; + logCfgFilename = (char*)malloc(len); + + if(logCfgFilename) { + cfgAlloc = 1; + snprintf(logCfgFilename, len, "%s/%s", cfgEnvPath, "logging.properties"); + } + } + } + + if(!logCfgFilename || !strlen(logCfgFilename)) { + FILE* file = ACE_OS::fopen("logging.properties", "r"); + if(file) + { + // logging.properties exists in the current directory + logCfgFilename = "logging.properties"; + fclose(file); + } + else + { + // logging.properties could not be found in the current + // directory, try to find it in system configuration directory + logCfgFilename = "/etc/orkaudio/logging.properties"; + } } // If this one fails, the above default configuration stays valid PropertyConfigurator::configure(logCfgFilename); + // XXX should we free this here? + if(cfgAlloc) { + free(logCfgFilename); + } + rootLog = Logger::getLogger("root"); topLog = Logger::getLogger("top"); immediateProcessingLog = Logger::getLogger("immediateProcessing"); -- cgit v1.2.3