Skip to content

ifs log enhancements#4086

Closed
krishanifs wants to merge 3 commits intopjsip:masterfrom
krishanifs:log_enhancements
Closed

ifs log enhancements#4086
krishanifs wants to merge 3 commits intopjsip:masterfrom
krishanifs:log_enhancements

Conversation

@krishanifs
Copy link
Copy Markdown

  • In pj_assert put logs in non-debug modes
  • Added PJ_ASSERT_LOG
  • In pjsua_reconfigure_logging gets log file name from config
  • Adding more logs

Copy link
Copy Markdown
Member

@nanangizz nanangizz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contributions :)

#ifdef _WIN32
#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#else
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Better avoid macro names using underscore prefixes (read somewhere it maybe reserved for system, sdk, etc), e.g: PJ_ASSERT_FILENAME?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this in #4098 due to a couple of reasons:

  • platform difficulty (as commented above).
  • if we want to extract the filename only and get rid of its path, perhaps we need to do it in the log instead. It has been previously discussed in PJ_LOG_HAS_FILENAME #3889.

#ifndef pj_assert
#include "pj/log.h"
#include <string.h>
#ifdef _WIN32
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Windows, it is possible to use MinGW, so need to confirm whether MinGW compiler has _WIN32 and uses \\ instead of / for path separator.


/* Redirect log function to ours */
pj_log_set_log_func( &log_writer );
pj_log_set_log_func( (cfg && cfg->cb && !cfg->log_filename.slen) ? cfg->cb : &log_writer );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We missed cfg != NULL verification, better add that, e.g: PJ_ASSERT_RETURN(cfg, PJ_EINVAL);
  • Re: skipping the log_writer, it may change the behavior of the lib (potential backward compatibility issue), could you specify the reason?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for the first one, the second one reverted to current code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pass a different log_writer call back function that write pj logs into our own application logs. how are we going to achieve that without this implementation.

Copy link
Copy Markdown
Member

@sauwming sauwming Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an optimization we added. it directly call 'cfg->cb' if user has defined that; without calling it through log_writer. But it is OK to stick with current implementation.

@sauwming sauwming mentioned this pull request Oct 4, 2024
Copy link
Copy Markdown
Member

@sauwming sauwming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will continue this in #4098.


/* Redirect log function to ours */
pj_log_set_log_func( &log_writer );
pj_log_set_log_func( (cfg && cfg->cb && !cfg->log_filename.slen) ? cfg->cb : &log_writer );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for the first one, the second one reverted to current code.

#ifdef _WIN32
#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#else
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this in #4098 due to a couple of reasons:

  • platform difficulty (as commented above).
  • if we want to extract the filename only and get rid of its path, perhaps we need to do it in the log instead. It has been previously discussed in PJ_LOG_HAS_FILENAME #3889.

@sauwming
Copy link
Copy Markdown
Member

sauwming commented Oct 4, 2024

Since we already create a separate PR to continue this, you need to create a new PR if you want to push a new commit, otherwise it will potentially cause conflicts when merged.

@krishanifs
Copy link
Copy Markdown
Author

sorry about the late commit but (41c0082) is also part of the log enhancement.

*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
PJ_DECL(pj_status_t) pjsua_create2(const pjsua_logging_config *log_cfg);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we can pass the log config to pjsua_init(), why is this new API needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants