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

George Joseph asteriskteam at digium.com
Wed Aug 25 09:09:20 CDT 2021


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

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


Patch Set 10: Code-Review-1

(1 comment)

File main/logger.c:

https://gerrit.asterisk.org/c/asterisk/+/16222/comment/c91a4cb5_7f039298 
PS10, Line 818: registercustomlevels:;
              : 		while ((logfile = strsep(&customlogs, ","))) {
              : 			unsigned int level;
              : 			/* 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)) {
              : 					/* need to continue the outer loop, not the inner loop */
              : 					goto registercustomlevels; /* already exists, skip */
              : 				}
              : 			}
              : 			/* Lock already held, so directly register the level */
              : 			logger_register_level(logfile);
              : 		}
Custom levels that were removed from the parameter don't get unregistered.

I think you're going to have to save the value of custom_levels in a global variable, then when you read the new value from the config file you can unregister any in the saved version that aren't in the new version and register any in the new version that aren't in the saved version.  Then you replace the saved version with the new version.

To make things easier, you should create internal versions of ast_logger_unregister_level and ast_logger_get_dynamic_level that don't do locking, (just like ast_logger_register_level and logger_register_level) so you can save a loop or two.  You could also use a regex to check if a new level exists in the saved version  or a saved level exists in the new version to avoid another nested loop.



-- 
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: 10
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-Attention: N A <mail at interlinked.x10host.com>
Gerrit-Attention: Joshua Colp <jcolp at sangoma.com>
Gerrit-Comment-Date: Wed, 25 Aug 2021 14:09:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210825/d6826d29/attachment.html>


More information about the asterisk-code-review mailing list