[Asterisk-code-review] logger: Add custom logging capabilities (asterisk[master])

N A asteriskteam at digium.com
Mon Sep 13 05:35:22 CDT 2021


Attention is currently required from: Joshua Colp, George Joseph, Kevin Harwell.
N A has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16222 )

Change subject: logger: Add custom logging capabilities
......................................................................


Patch Set 14:

(5 comments)

File main/logger.c:

https://gerrit.asterisk.org/c/asterisk/+/16222/comment/60b61da7_9035b083 
PS12, Line 831: int custom_level, found = 0;
              : 			/* if we are reloading, we don't want to re-register levels that exist */
              : 			for (level = 16; level < ARRAY_LEN(levels); level++) {
              : 				if (levels[level] && !strcasecmp(levels[level], logfile)) {
              : 					found = 1; /* already exists, skip */
              : 					break;
              : 				}
              : 			}
> I believe you can just call 'ast_logger_get_dynamic_level' here?
Not quite, because that results in a deadlock, but I added a logger_get_dynamic_level which allows the simplification.


https://gerrit.asterisk.org/c/asterisk/+/16222/comment/83b26bf6_fa7cfb69 
PS12, Line 847: 		for (level = 16; level < ARRAY_LEN(levels); level++) {
              : 			if (levels[level] && custom_dynamic_levels[level]) {
              : 				int level2, found = 0;
              : 				for (level2 = 16; level2 < ARRAY_LEN(levels); level2++) {
              : 					if (levels[level2] && !strcasecmp(levels[level2], levels[level])) {
              : 						found = 1; /* level still exists, skip */
              : 						break;
              : 					}
              : 				}
> This might could be simplified if you instead loop over the custom_dynamic_levels, and then you can  […]
Not quite sure I follow... can you elaborate on this?
I'm able to simplify it quite a bit if I do it before, but not sure how to take that further.


https://gerrit.asterisk.org/c/asterisk/+/16222/comment/69d7c486_b020cf34 
PS12, Line 846: 		/* unregister existing custom levels which don't exist anymore */
              : 		for (level = 16; level < ARRAY_LEN(levels); level++) {
              : 			if (levels[level] && custom_dynamic_levels[level]) {
              : 				int level2, found = 0;
              : 				for (level2 = 16; level2 < ARRAY_LEN(levels); level2++) {
              : 					if (levels[level2] && !strcasecmp(levels[level2], levels[level])) {
              : 						found = 1; /* level still exists, skip */
              : 						break;
              : 					}
              : 				}
              : 				if (!found) {
              : 					logger_unregister_level(levels[level]);
              : 					custom_dynamic_levels[level] = 0;
              : 				}
              : 			}
              : 		}
> Probably want to remove the deleted items prior to [re]loading new ones as removing will free up pos […]
Done


https://gerrit.asterisk.org/c/asterisk/+/16222/comment/17e71557_e8e3ea44 
PS12, Line 2604: 	unsigned int found = 0;
               : 	unsigned int x;
               : 
               : 	for (x = 16; x < ARRAY_LEN(levels); x++) {
               : 		if (!levels[x]) {
               : 			continue;
               : 		}
               : 
               : 		if (strcasecmp(levels[x], name)) {
               : 			continue;
               : 		}
               : 
               : 		found = 1;
               : 		break;
               : 	}
               : 
               : 	if (found) {
               : 		/* take this level out of the global_logmask, to ensure that no new log messages
               : 		 * will be queued for it
               : 		 */
               : 
               : 		global_logmask &= ~(1 << x);
               : 
               : 		ast_free(levels[x]);
               : 		levels[x] = NULL;
               : 		return x;
               : 	}
               : 
               : 	return 0;
> Could this whole method be reduced to: […]
Done


https://gerrit.asterisk.org/c/asterisk/+/16222/comment/0ba29035_13a5b3a5 
PS12, Line 2637: 	int x;
               : 
               : 	AST_RWLIST_WRLOCK(&logchannels);
               : 	x = logger_unregister_level(name);
               : 
               : 	if (x) {
               : 		AST_RWLIST_UNLOCK(&logchannels);
               : 
               : 		ast_debug(1, "Unregistered dynamic logger level '%s' with index %u.\n", name, x);
               : 
               : 		AST_RWLIST_WRLOCK(&logchannels);
               : 		update_logchannels();
               : 		AST_RWLIST_UNLOCK(&logchannels);
               : 	} else {
               : 		AST_RWLIST_UNLOCK(&logchannels);
               : 	}
               : }
> Seems odd to just have to unlock for the debug message. […]
Done



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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: If082703cf81a436ae5a565c75225fa8c0554b702
Gerrit-Change-Number: 16222
Gerrit-PatchSet: 14
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: N A <mail at interlinked.x10host.com>
Gerrit-Attention: Joshua Colp <jcolp at sangoma.com>
Gerrit-Attention: George Joseph <gjoseph at digium.com>
Gerrit-Attention: Kevin Harwell <kharwell at digium.com>
Gerrit-Comment-Date: Mon, 13 Sep 2021 10:35:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210913/805148a0/attachment-0001.html>


More information about the asterisk-code-review mailing list