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

Getting some extra debug output from v0.4.1 #24

Open
define-private-public opened this issue Jun 15, 2017 · 6 comments
Open

Getting some extra debug output from v0.4.1 #24

define-private-public opened this issue Jun 15, 2017 · 6 comments

Comments

@define-private-public
Copy link
Contributor

Thanks for pushing a working version. While My application still works, it's showing a lot of extra debug information on the terminal. For example:

Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
storage 0xffffffff, but handle 0x00000000?
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
PTP_OC 0x9153 receiving resp failed: Camera Not Ready (0xa102)
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
Error during assembling of port list: 'Unspecified error' (-1).
PTP_OC 0x9152 receiving resp failed: PTP Operation Not Supported (0x2005)
PTP_OC 0x911c receiving resp failed: PTP Device Busy (0x2019)
'ptp_canon_eos_resetuilock (params)' failed: PTP Device Busy (0x2019)

that Error during assembling... message comes about once per second. Since I setup a loop to call (a slightly modified version of) list_cameras(). Is there I way I can suppress this extra info?

@jbaiter
Copy link
Owner

jbaiter commented Jun 16, 2017

The new version automatically maps from gphoto2 logging levels to the corresponding Python logging levels: https://github.com/jbaiter/gphoto2-cffi/blob/master/gphoto2cffi/backend.py#L45, https://github.com/jbaiter/gphoto2-cffi/blob/master/gphoto2cffi/backend.py#L75
So it should be enough to use Python's standard logging mechanisms to filter out certain loggers and/or log levels.

@define-private-public
Copy link
Contributor Author

define-private-public commented Jun 17, 2017

My preference would be to have logging off by default. Then let the user enable/disable it.

Would it be possible to add some module level variable in backend.py, where _logging_callback() has an if statement in it to see if it should print or ignore the log message? We could then add the functions enable_logging()/disable_logging() to backend.py or the LibraryWrapepr class. I'm a little fuzzy on how module level variable scope work in python.

If that seems okay to you, I can test it out and submit a PR for that.

@jbaiter
Copy link
Owner

jbaiter commented Jun 18, 2017

I'm not really a fan of the module-level variable... We could instead set the default logging level for the library to logging.CRITICAL (so that errors and warnings will not be printed by default). If a user wants to see more messages, he can just call e.g. logging.getLogger('libgphoto2').setLevel(logging.ERROR). It should suffice to add LOGGER.setLevel(logging.CRITICAL) at https://github.com/jbaiter/gphoto2-cffi/blob/master/gphoto2cffi/backend.py#L11

@define-private-public
Copy link
Contributor Author

What about moving the _logging_callback() into the LibraryWrapper class as a static method, put that module level variable in the LibraryWrapper instead, and add a check at the beginning of _logging_callback()?

It gets rid of the module level variable, and since lib should be only instantiated once IIRC, they should be able to do something like:

from gphoto2cffi.backend import lib
lib.logging_enabled = True

@define-private-public
Copy link
Contributor Author

I also think that CRITICAL should be left for well..., critical errors.

@jbaiter
Copy link
Owner

jbaiter commented Jun 19, 2017

Well, it would still be, since the library does not log with CRITICAL at all. The effect of setting that level would be to silence the logger as much as possible by default. Your proposal with the LibraryWrapper looks good, though :-)

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

No branches or pull requests

2 participants