Signed-off-by: Pesala Silva <[email protected]> Log_Enhacements for pjproject 2.13#4546
Signed-off-by: Pesala Silva <[email protected]> Log_Enhacements for pjproject 2.13#4546PesalaDeSilva wants to merge 3 commits intopjsip:masterfrom
Conversation
…d_changes_for_PJSIP_2.13
…ed changes for this log enhancement
There was a problem hiding this comment.
Pull Request Overview
This PR enhances logging functionality in PJSIP 2.13 by improving log message detail and fixing log function configuration. The changes add call ID and destination URI information to transport messages and allow proper callback function usage in logging configuration.
- Enhanced SIP message logging with additional Call-ID and To header information
- Fixed log function configuration to properly handle custom callback functions
- Minor code formatting cleanup (whitespace removal)
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pjsip/src/pjsua-lib/pjsua_core.c | Fixes log function configuration to use custom callback when appropriate |
| pjsip/src/pjsip/sip_transport.c | Enhances message logging with Call-ID and To header information |
| pjlib/src/pj/os_core_win32.c | Adds trailing newlines for formatting consistency |
| pjlib/include/pj/assert.h | Removes unnecessary blank line |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pjsip/src/pjsip/sip_transport.c
Outdated
| const pjsip_msg *msg) | ||
| { | ||
| char info_buf[128], *info; | ||
| char info_buf[256], to_uri[PJSIP_MAX_URL_SIZE], * info; |
There was a problem hiding this comment.
[nitpick] The spacing around the asterisk in '* info' is inconsistent with C style conventions. It should be 'char info_buf[256], to_uri[PJSIP_MAX_URL_SIZE], *info;' with the asterisk attached to the variable name.
| char info_buf[256], to_uri[PJSIP_MAX_URL_SIZE], * info; | |
| char info_buf[256], to_uri[PJSIP_MAX_URL_SIZE], *info; |
pjsip/src/pjsip/sip_transport.c
Outdated
| cid = (const pjsip_cid_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CALL_ID, NULL); | ||
| to = (const pjsip_to_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_TO, NULL); | ||
| len = (to && to->uri) ? pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, to->uri, to_uri, sizeof(to_uri)) : 0; | ||
| to_uri[((len > 0) && (len < sizeof(to_uri))) ? len : 0] = '\0'; |
There was a problem hiding this comment.
[nitpick] The complex ternary expression makes the null termination logic difficult to read. Consider breaking this into clearer conditional logic: 'if (len > 0 && len < sizeof(to_uri)) { to_uri[len] = '\0'; } else { to_uri[0] = '\0'; }'
| to_uri[((len > 0) && (len < sizeof(to_uri))) ? len : 0] = '\0'; | |
| if (len > 0 && len < (int)sizeof(to_uri)) { | |
| to_uri[len] = '\0'; | |
| } else { | |
| to_uri[0] = '\0'; | |
| } |
pjsip/src/pjsip/sip_transport.c
Outdated
| cseq->cseq, | ||
| cid ? "/cid=" : "", cid ? (int)cid->id.slen : 0, cid ? cid->id.ptr : "", | ||
| to_uri[0] ? "/to=" : "", to_uri, | ||
| obj_name); |
There was a problem hiding this comment.
[nitpick] The format string with multiple consecutive %s specifiers makes it difficult to understand the output format. Consider using more descriptive format strings or breaking this into multiple sprintf calls for better readability.
|
I think the added information is a bit excessive. The detail message content can be printed by enabling |
|
Thank you for the PR submission. We’ve accepted most of the log enhancement contributions in #4086. However, regarding the additional SIP transport log in this PR, we believe it’s best to keep the current behavior. While the change does provide more detailed information, it also introduces extra overhead in terms of printing and memory buffer required. If your application requires more detailed logging, we recommend enabling |
|
Another alternative is to introduce a compile-time setting such as If you choose option b, there's nothing to do on your part. We will create a new PR based on your PR. If you choose a, then we will close the PR. |
|
Completed with additional compile-time option in #4560 |
This PR for the Log Enhancements and modifications done for logs for better information for PJSIP 2.13 version