Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24.toggle debugging #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

define-private-public
Copy link
Contributor

Addressing #24, the programmer can now toggle logging on and off. I did this without using statics. Instead I created a wrapper function (inside of __init__) that will check if self.enable_logging is True or False. And dependent upon that, it will actually log the message.

Also it bumps up the version number to 0.4.2. If this looks good, please do a push to PyPi.

@@ -131,6 +123,22 @@ def __getattr__(self, name):
else:
return val

def _logging_callback(self, level, domain, message, data):
Copy link
Owner

Choose a reason for hiding this comment

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

Does this have to be an instance method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it doesn't. It's an artifact of older code.

Originally I had the if self.logging_enabled check in there, but then I moved it up to the wrapper in __init__(). We have three options:

  1. Leave it be and merge the pull request. No harm done
  2. Move the if self.logging_enabled back to the _logging_callback() function. This would make it a little more clean if we wanted to add some other features to LibraryWrapper that effect logging
  3. Move the body of _logging_callback() to _logging_callback_wrapper() in __init__().

Which one do you want?

Copy link
Owner

@jbaiter jbaiter Jun 20, 2017

Choose a reason for hiding this comment

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

Have you tried getting rid of the inner wrapper function with 2)? I'm not sure how cffi handles callbacks that are bound instance methods, but that would probably the cleanest way from a readability perspective. Otherwise I'd probably go with 3) :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instance methods didn't worked as I hoped that they would. I'll make the modifications for No. 3 and update the pull request.

@define-private-public
Copy link
Contributor Author

After some testing I think this solution might have been incorrect. I swear it was working last night where it would let me toggle logging in my application.

Could you try pulling down this branch and see if it works for you?

@define-private-public
Copy link
Contributor Author

I'm thinking that there might have been some threading issue with this.

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.

None yet

2 participants