[asterisk-scf-commits] asterisk-scf/release/logger.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Sep 22 15:23:12 CDT 2011


branch "master" has been updated
       via  19678a832f728be13b5230e56b5b5e7db6ddf5d4 (commit)
      from  2f13e1c4e013cc20d3672df8029502c6836613c1 (commit)

Summary of changes:
 server/config/LoggerConfigurator.py |   65 +++++++++++++++++++----------------
 server/src/FileChainedLogOut.cpp    |   10 ++++-
 2 files changed, 43 insertions(+), 32 deletions(-)


- Log -----------------------------------------------------------------
commit 19678a832f728be13b5230e56b5b5e7db6ddf5d4
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Thu Sep 22 15:20:50 2011 -0500

    Corrected log config file handling. Special handling for quoted config values required.

diff --git a/server/config/LoggerConfigurator.py b/server/config/LoggerConfigurator.py
index 26251cb..a9ac6f4 100644
--- a/server/config/LoggerConfigurator.py
+++ b/server/config/LoggerConfigurator.py
@@ -27,9 +27,9 @@ import AsteriskSCF.Configuration.LoggingService.V1
 class LoggingServiceSectionVisitors(Configurator.SectionVisitors):
 
     def getLevel(self, levelName):
-	levelName = levelName.strip()
-	if levelName == 'Trace':
-	    return AsteriskSCF.System.Logging.Level.Trace
+        levelName = levelName.strip()
+        if levelName == 'Trace':
+            return AsteriskSCF.System.Logging.Level.Trace
         elif levelName == 'Debug':
             return AsteriskSCF.System.Logging.Level.Debug
         elif levelName == 'Info':
@@ -53,41 +53,46 @@ class LoggingServiceSectionVisitors(Configurator.SectionVisitors):
 
     def visit_general(self, config, section):
         group = AsteriskSCF.Configuration.LoggingService.V1.LoggerGeneralGroup()
-	group.name = section
+        group.name = section
         group.configurationItems = { }
 
-        mapper = Configurator.OptionMapper()
-
-	try:
-	    levels = config.get(section, 'levels')
-	    levelsList = levels.split(';')
-	    levelItemCount = 0
-	    for levelSpec in levelsList:
+        try:
+            levels = config.get(section, 'levels')
+            levelsList = levels.split(';')
+            levelItemCount = 0
+            for levelSpec in levelsList:
                 levelParts = levelSpec.split(',')
-		logLevel = self.getLevel(levelParts[0])
-		loggerName = levelParts[1]
-#		print "logLevel = {0} and loggerName = {1}".format(logLevel, loggerName)
-		levelItem =  AsteriskSCF.Configuration.LoggingService.V1.LevelItem()
+                logLevel = self.getLevel(levelParts[0])
+                loggerName = levelParts[1]
+#               print "logLevel = {0} and loggerName = {1}".format(logLevel, loggerName)
+                levelItem =  AsteriskSCF.Configuration.LoggingService.V1.LevelItem()
 
                 levelItem.loggingLevel = logLevel
-		levelItem.loggerName = loggerName
-		group.configurationItems['loggingLevel' + `levelItemCount`] = levelItem
-		levelItemCount = levelItemCount + 1
-	except ConfigParser.NoOptionError:
-		pass
-
+                levelItem.loggerName = loggerName
+                group.configurationItems['loggingLevel' + `levelItemCount`] = levelItem
+                levelItemCount = levelItemCount + 1
+        except ConfigParser.NoOptionError:
+            pass
+
+        # Not using the mapper for filename because we want to strip the double quotes off the strings. 
+        # Filenames must be double-quoted in the config file to support spaces in filenames. 
         fileItem = AsteriskSCF.Configuration.LoggingService.V1.FileItem()
-	mapper.map('filename', fileItem, 'fileName', 'filename', config.get, None)
-
+        fileName = config.get(section, 'filename')
+        fileName = fileName.strip('\"')
+        fileName = fileName.strip()
+        fileItem.fileName = fileName
+        group.configurationItems['filename'] = fileItem
+
+        # Similarly to filenames, the format is double quoted in the config file 
+        # because format strings can have spaces. 
         formatItem = AsteriskSCF.Configuration.LoggingService.V1.FormatItem()
-	mapper.map('format', formatItem, 'formatSpec', 'format', config.get, None)
-
-        for option in config.options(section):
-            mapper.execute(group, section, option)
-
-        mapper.finish(group)
+        formatString = config.get(section, 'format')
+        formatString = formatString.strip('\"')
+        formatString = formatString.strip()
+        formatItem.formatSpec = formatString
+        group.configurationItems['format'] = formatItem
 
-	self.groups.append(group)
+        self.groups.append(group)
 
 # In order to do service locator based lookup we need to pass in a params object
 serviceLocatorParams = AsteriskSCF.Core.Discovery.V1.ServiceLocatorParams()
diff --git a/server/src/FileChainedLogOut.cpp b/server/src/FileChainedLogOut.cpp
index ad9abd9..3b56776 100644
--- a/server/src/FileChainedLogOut.cpp
+++ b/server/src/FileChainedLogOut.cpp
@@ -13,7 +13,9 @@
  * the GNU General Public License Version 2. See the LICENSE.txt file
  * at the top of the source tree.
  */
+#include <iostream>
 #include <fstream>
+#include <cerrno>
 #include <IceUtil/IceUtil.h>
 
 #include "FileChainedLogOut.h"
@@ -32,8 +34,12 @@ void FileChainedLogOut::myLogs(const std::string& name, Level logLevel,
     IceUtil::Mutex::Lock lock(mFileMutex);
     if (!mOut || !mOut.is_open())
     {
-        // reopen the file
-        mOut.open(mLogFile.c_str(), std::ios::out);
+        // open the file
+        mOut.open(mLogFile);
+        if (mOut.fail())
+        {
+             std::cerr << "Logger error opening output file " << mLogFile << " due to: " << strerror(errno) << '\n';
+        }
     }
 
     if (mOut && mOut.is_open())

-----------------------------------------------------------------------


-- 
asterisk-scf/release/logger.git



More information about the asterisk-scf-commits mailing list