[Asterisk-code-review] res_pjproject: Allow mapping to Asterisk TRACE level (asterisk[19])

George Joseph asteriskteam at digium.com
Mon Aug 16 10:10:41 CDT 2021


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/16281 )


Change subject: res_pjproject: Allow mapping to Asterisk TRACE level
......................................................................

res_pjproject: Allow mapping to Asterisk TRACE level

Allow mapping pjproject log messages to the Asterisk TRACE
log level.  The defaults were also changes to log pjproject
levels 3,4 to DEBUG and 5,6 to TRACE.  Previously 3,4,5,6
all went to DEBUG.

ASTERISK-29582

Change-Id: I859a37a8dec263ed68099709cfbd3e665324c72d
---
M configs/samples/pjproject.conf.sample
M res/res_pjproject.c
2 files changed, 21 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/81/16281/1

diff --git a/configs/samples/pjproject.conf.sample b/configs/samples/pjproject.conf.sample
index 03149c4..273384b 100644
--- a/configs/samples/pjproject.conf.sample
+++ b/configs/samples/pjproject.conf.sample
@@ -52,5 +52,8 @@
                      ; (default: "")
 ;asterisk_debug =    ; A comma separated list of pjproject log levels to map to
                      ; Asterisk debug
-                     ; (default: "3,4,5,6")
+                     ; (default: "3,4")
+;asterisk_trace =    ; A comma separated list of pjproject log levels to map to
+                     ; Asterisk trace
+                     ; (default: "5,6")
 ;type=               ; Must be of type log_mappings (default: "")
diff --git a/res/res_pjproject.c b/res/res_pjproject.c
index f6dce4c..4047aca 100644
--- a/res/res_pjproject.c
+++ b/res/res_pjproject.c
@@ -29,7 +29,10 @@
  *  - 0: LOG_ERROR
  *  - 1: LOG_ERROR
  *  - 2: LOG_WARNING
- *  - 3 and above: equivalent to ast_debug(level, ...) for res_pjproject.so
+ *  - 3: equivalent to ast_debug(level, ...) for res_pjproject.so
+ *  - 4: equivalent to ast_debug(level, ...) for res_pjproject.so
+ *  - 5: equivalent to ast_trace(level, ...) for res_pjproject.so
+ *  - 6: equivalent to ast_trace(level, ...) for res_pjproject.so
  */
 
 /*** MODULEINFO
@@ -86,12 +89,15 @@
 				<configOption name="asterisk_notice" default="">
 					<synopsis>A comma separated list of pjproject log levels to map to Asterisk LOG_NOTICE.</synopsis>
 				</configOption>
-				<configOption name="asterisk_debug" default="3,4,5,6">
-					<synopsis>A comma separated list of pjproject log levels to map to Asterisk LOG_DEBUG.</synopsis>
-				</configOption>
 				<configOption name="asterisk_verbose" default="">
 					<synopsis>A comma separated list of pjproject log levels to map to Asterisk LOG_VERBOSE.</synopsis>
 				</configOption>
+				<configOption name="asterisk_debug" default="3,4">
+					<synopsis>A comma separated list of pjproject log levels to map to Asterisk LOG_DEBUG.</synopsis>
+				</configOption>
+				<configOption name="asterisk_trace" default="5,6">
+					<synopsis>A comma separated list of pjproject log levels to map to Asterisk LOG_TRACE.</synopsis>
+				</configOption>
 			</configObject>
 		</configFile>
 	</configInfo>
@@ -148,6 +154,8 @@
 		AST_STRING_FIELD(asterisk_verbose);
 		/*! pjproject log levels mapped to Asterisk DEBUG */
 		AST_STRING_FIELD(asterisk_debug);
+		/*! pjproject log levels mapped to Asterisk TRACE */
+		AST_STRING_FIELD(asterisk_trace);
 	);
 };
 
@@ -190,6 +198,8 @@
 		mapped_level = __LOG_VERBOSE;
 	} else if (strchr(mappings->asterisk_debug, l)) {
 		mapped_level = __LOG_DEBUG;
+	} else if (strchr(mappings->asterisk_trace, l)) {
+		mapped_level = __LOG_TRACE;
 	} else {
 		mapped_level = __LOG_SUPPRESS;
 	}
@@ -675,6 +685,7 @@
 	ast_sorcery_object_field_register(pjproject_sorcery, "log_mappings", "asterisk_warning", "",  OPT_STRINGFIELD_T, 0, STRFLDSET(struct log_mappings, asterisk_warning));
 	ast_sorcery_object_field_register(pjproject_sorcery, "log_mappings", "asterisk_notice", "",  OPT_STRINGFIELD_T, 0, STRFLDSET(struct log_mappings, asterisk_notice));
 	ast_sorcery_object_field_register(pjproject_sorcery, "log_mappings", "asterisk_verbose", "",  OPT_STRINGFIELD_T, 0, STRFLDSET(struct log_mappings, asterisk_verbose));
+	ast_sorcery_object_field_register(pjproject_sorcery, "log_mappings", "asterisk_trace", "",  OPT_STRINGFIELD_T, 0, STRFLDSET(struct log_mappings, asterisk_trace));
 
 	default_log_mappings = ast_sorcery_alloc(pjproject_sorcery, "log_mappings", "log_mappings");
 	if (!default_log_mappings) {
@@ -683,7 +694,8 @@
 	}
 	ast_string_field_set(default_log_mappings, asterisk_error, "0,1");
 	ast_string_field_set(default_log_mappings, asterisk_warning, "2");
-	ast_string_field_set(default_log_mappings, asterisk_debug, "3,4,5,6");
+	ast_string_field_set(default_log_mappings, asterisk_debug, "3,4");
+	ast_string_field_set(default_log_mappings, asterisk_trace, "5,6");
 
 	ast_sorcery_load(pjproject_sorcery);
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I859a37a8dec263ed68099709cfbd3e665324c72d
Gerrit-Change-Number: 16281
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210816/792a2d60/attachment-0001.html>


More information about the asterisk-code-review mailing list