[svn-commits] kmoore: branch 10 r331654 - in /branches/10: ./ main/logger.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Aug 12 11:21:41 CDT 2011


Author: kmoore
Date: Fri Aug 12 11:21:37 2011
New Revision: 331654

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=331654
Log:
Merged revisions 331649 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r331649 | kmoore | 2011-08-12 11:20:25 -0500 (Fri, 12 Aug 2011) | 12 lines
  
  Logger does not warn of failure to open logging channels
  
  Currently, logger only prints an error message to stderr when it fails to open
  a logger channel where many users will not see it because the logger lock is
  held.  The alternative provided by this patch is to log the error to all
  attached consoles in the hopes that it will be easier to see.  Additionally,
  this patch prevents the failed logger channel from being added to the list
  where it would silently fail on each call to the Asterisk logger.
  
  (closes issue ASTERISK-16231)
  Review: https://reviewboard.asterisk.org/r/1338
........

Modified:
    branches/10/   (props changed)
    branches/10/main/logger.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/logger.c?view=diff&rev=331654&r1=331653&r2=331654
==============================================================================
--- branches/10/main/logger.c (original)
+++ branches/10/main/logger.c Fri Aug 12 11:21:37 2011
@@ -274,9 +274,16 @@
 				 channel[0] != '/' ? ast_config_AST_LOG_DIR : "", channel);
 		}
 		if (!(chan->fileptr = fopen(chan->filename, "a"))) {
-			/* Can't log here, since we're called with a lock */
-			fprintf(stderr, "Logger Warning: Unable to open log file '%s': %s\n", chan->filename, strerror(errno));
-		} 
+			/* Can't do real logging here since we're called with a lock
+			 * so log to any attached consoles */
+			ast_console_puts_mutable("ERROR: Unable to open log file '", __LOG_ERROR);
+			ast_console_puts_mutable(chan->filename, __LOG_ERROR);
+			ast_console_puts_mutable("': ", __LOG_ERROR);
+			ast_console_puts_mutable(strerror(errno), __LOG_ERROR);
+			ast_console_puts_mutable("'\n", __LOG_ERROR);
+			ast_free(chan);
+			return NULL;
+		}
 		chan->type = LOGTYPE_FILE;
 	}
 	chan->logmask = make_components(chan->components, lineno);
@@ -384,6 +391,11 @@
 	var = ast_variable_browse(cfg, "logfiles");
 	for (; var; var = var->next) {
 		if (!(chan = make_logchannel(var->name, var->value, var->lineno))) {
+			/* Print error message directly to the consoles since the lock is held
+			 * and we don't want to unlock with the list partially built */
+			ast_console_puts_mutable("ERROR: Unable to create log channel '", __LOG_ERROR);
+			ast_console_puts_mutable(var->name, __LOG_ERROR);
+			ast_console_puts_mutable("'\n", __LOG_ERROR);
 			continue;
 		}
 		AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);




More information about the svn-commits mailing list