diff options
author | Gerald Begumisa <ben_g@users.sourceforge.net> | 2007-07-19 09:34:07 +0000 |
---|---|---|
committer | Gerald Begumisa <ben_g@users.sourceforge.net> | 2007-07-19 09:34:07 +0000 |
commit | abf1495c5e6e33a93a0277ef301643e7ff2ab4dd (patch) | |
tree | dc8a36564f3760f36060b5a1c0c9a6f07ef444fc /orkbasecxx/LogManager.cpp | |
parent | a78ef547ae120f95a2569c9643cd60992ba547c7 (diff) |
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 <CommandLineServerPort> and <HttpServerPort> 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
Diffstat (limited to 'orkbasecxx/LogManager.cpp')
-rw-r--r-- | orkbasecxx/LogManager.cpp | 53 |
1 files changed, 41 insertions, 12 deletions
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 <log4cxx/propertyconfigurator.h> #include <log4cxx/basicconfigurator.h> @@ -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"); |