[Asterisk-code-review] logger.c: Fix default console logging when no logger.conf av... (asterisk[master])

George Joseph asteriskteam at digium.com
Thu Oct 25 07:37:50 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/10537 )

Change subject: logger.c: Fix default console logging when no logger.conf available.
......................................................................

logger.c: Fix default console logging when no logger.conf available.

Default logging was not setup correctly when there was no logger.conf.
This resulted in many expected log messages not actually getting out to
the console.

Change-Id: I542e61c03b2f630ff5327f9de5641d776c6fa70c
---
M main/logger.c
1 file changed, 7 insertions(+), 8 deletions(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  George Joseph: Approved for Submit



diff --git a/main/logger.c b/main/logger.c
index 57e5857..ff781b1 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -621,7 +621,8 @@
 	return chan;
 }
 
-/* \brief Read config, setup channels.
+/*!
+ * \brief Read config, setup channels.
  * \param altconf Alternate configuration file to read.
  *
  * \pre logchannels list is write locked
@@ -663,14 +664,11 @@
 
 	/* If no config file, we're fine, set default options. */
 	if (!cfg) {
-		if (!(chan = ast_calloc(1, sizeof(*chan) + 1))) {
-			fprintf(stderr, "Failed to initialize default logging\n");
+		chan = make_logchannel("console", "error,warning,notice,verbose", 0, 0);
+		if (!chan) {
+			fprintf(stderr, "ERROR: Failed to initialize default logging\n");
 			return -1;
 		}
-		chan->type = LOGTYPE_CONSOLE;
-		chan->logmask = (1 << __LOG_WARNING) | (1 << __LOG_NOTICE) | (1 << __LOG_ERROR)
-			| (1 << __LOG_VERBOSE);
-		memcpy(&chan->formatter, &logformatter_default, sizeof(chan->formatter));
 
 		AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
 		global_logmask |= chan->logmask;
@@ -738,7 +736,8 @@
 
 	var = ast_variable_browse(cfg, "logfiles");
 	for (; var; var = var->next) {
-		if (!(chan = make_logchannel(var->name, var->value, var->lineno, 0))) {
+		chan = make_logchannel(var->name, var->value, var->lineno, 0);
+		if (!chan) {
 			/* 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);

-- 
To view, visit https://gerrit.asterisk.org/10537
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I542e61c03b2f630ff5327f9de5641d776c6fa70c
Gerrit-Change-Number: 10537
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181025/baf13b1d/attachment.html>


More information about the asterisk-code-review mailing list