Skip to content

Conversation

@BlackJohnny
Copy link
Contributor

@BlackJohnny BlackJohnny commented Sep 25, 2019

Fixes #5620

Added support for Python native logging within the Pulsar Client Python wrapper.

  • added a new Logger implementation that forwards the logging to python
  • updated the python module to allow setting the logger on a pulsar.Client via the ClientConfiguration object

Tested with tag/2.4.1

Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

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

The change LGTM, just one comment on making more efficient the checking for log level.

Py_XDECREF(_pyLogger);
}

bool isEnabled(Level level) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be overkill to get back into Python each time to check the log level. This will be called many times (eg. for the debug statements). is the logging level supposed to be changed frequently at runtime? Could we cache it in c++ land and only check on python every 1sec or so?

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, we have a RateLimiter in the perf directory. We could try to reuse the same class to "limit" the number of times/s we're checking what's the current log level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion! It seems to me that RateLimiter blocks the caller and I think that it's not the intended behavior. Please correct me if I am wrong.

Taking into account that in real life you would not want to change the level at run-time very often, I propose the following options:

Solution 1:

  • Initialize a class member currentLoggingLevel during the construction of the Logger, by calling the python's "logger.getEffectiveLevel()". Then never update this value. This would imply that whenever the python programmer wants to change the logging behavior he would have to recycle the Client object.

Solution 2:

  • Add an internal counter to the logger and only forward the call to python each Nth time Logger::isEnabled is called.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the suggestion! It seems to me that RateLimiter blocks the caller and I think that it's not the intended behavior. Please correct me if I am wrong.

Oh, that's right. I confused with the Java RateLimiter class which also has tryAcquire() which is non-blocking.

Solution 1:

I think that should be fine to start with

Solution 2:

It might be tricky to understand "when" the change is taken into account

Another possibility could be to just update a timestamp of the last time the effective level was refreshed. If it was more than 1sec, then refresh it and update the timer. There should be no need of synchronization, since it doesn't have to be perfectly correct.

@merlimat merlimat added the type/feature The PR added a new feature or issue requested a new feature label Sep 25, 2019
@merlimat merlimat added this to the 2.5.0 milestone Sep 25, 2019
Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

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

👍

@jiazhai
Copy link
Member

jiazhai commented Sep 27, 2019

run integration tests

1 similar comment
@merlimat
Copy link
Contributor

run integration tests

@BlackJohnny
Copy link
Contributor Author

May I please have some help or hints with the Integration Tests? To say the least, I am not familiar enough with the project to know how to start fixing this issue.

Thank you!

@jiazhai
Copy link
Member

jiazhai commented Sep 29, 2019

run integration tests

@jiazhai
Copy link
Member

jiazhai commented Sep 30, 2019

run integration tests

@jiazhai
Copy link
Member

jiazhai commented Sep 30, 2019

@BlackJohnny, above comments "run integration tests" is a trigger for the jenkins integration tests, github will handle it.

@merlimat
Copy link
Contributor

merlimat commented Oct 7, 2019

run integration tests

1 similar comment
@jiazhai
Copy link
Member

jiazhai commented Oct 9, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Oct 24, 2019

run integration tests

1 similar comment
@jiazhai
Copy link
Member

jiazhai commented Nov 6, 2019

run integration tests

@merlimat
Copy link
Contributor

run integration tests

7 similar comments
@sijie
Copy link
Member

sijie commented Nov 12, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Nov 25, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Nov 26, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Nov 27, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Nov 28, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Nov 28, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Nov 29, 2019

run integration tests

@sijie
Copy link
Member

sijie commented Nov 29, 2019

@BlackJohnny do you mind rebasing this pull request to latest master to include some of the test fixes? I can't do it since you are creating a pull request based on the master of your fork.

@sijie sijie modified the milestones: 2.5.0, 2.6.0 Dec 1, 2019
@BlackJohnny
Copy link
Contributor Author

@BlackJohnny do you mind rebasing this pull request to latest master to include some of the test fixes? I can't do it since you are creating a pull request based on the master of your fork.

Done. Is it moved to 2.6 because of my late reaction?

@sijie
Copy link
Member

sijie commented Dec 4, 2019

@BlackJohnny the community is currently deploying a time based release schedule. so I move the issue to 2.6.0 since I wasn't sure when this pull request will be taken care of as this pull request was made of your master branch and I can't change it.

@jiazhai
Copy link
Member

jiazhai commented Dec 17, 2019

retest this please

1 similar comment
@jiazhai
Copy link
Member

jiazhai commented Dec 18, 2019

retest this please

@BlackJohnny
Copy link
Contributor Author

@merlimat, @jiazhai What can I do to avoid the risk of not having this pull-request included in 2.6.0? The best solution should be the one that would trigger a merge sooner than the moment when 2.6.0 is about to be released. Please let me know what should I do to make this happen. Thanks!

@sijie
Copy link
Member

sijie commented Jan 20, 2020

@BlackJohnny Can you please rebase this pull request to latest master? Also it would be good to send the pull request from a non-master branch. The committers can help you rebase branch to latest master as needed.

@BlackJohnny
Copy link
Contributor Author

Recreated pull-request from non-master branch Support for python native logging from python wrapper #6113

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

Labels

type/feature The PR added a new feature or issue requested a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cpp/python API: please log to stderr instead of stdout by default

4 participants