jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
362 stars 59 forks source link

gp.use_python_logging with non-root logger #60

Closed MikeTough closed 5 years ago

MikeTough commented 6 years ago

Hi Jim,

Firstly many, many thanks for your python bindings for gphoto. They have been working flawlessly for me so far. (gphoto2, on the other hand, is a bit of a handful - but I'm gradually getting the hang of it :) :) )

I have a query regarding your gp.use_python_logging function. With the exception of the information in your "ReadMe" file, I cannot find any description of the possible parameters for this function. (pydoc gphoto2 does not contain any info on this). Do you have a list of the possible parameters? (or is it limited to the mapping parameter?)

When redirecting the output of the DEBUG information from gphoto (as per the ReadMe example), the function appears to direct all output to the root logger. In my application the camera functions are only a small part of a larger whole and it would be convenient to send the log to a defined child logger of the root rather than directly to the root itself. Is this possible with the bindings as it stands?

Regards

Mike Tough

jim-easterbrook commented 6 years ago

The mapping is the only parameter to use_python_logging. The logging should be sent to a 'gphoto2' logger (see line 194 of the source file port_log.i). https://github.com/jim-easterbrook/python-gphoto2/blob/master/src/gphoto2/port_log.i#L178

PS pydoc gphoto2.use_python_logging works on my computer. PPS But pydoc gphoto2 doesn't mention it, as you've found. How odd.

jim-easterbrook commented 6 years ago

The pydoc problem is to do with use_python_logging being written in Python (nearly all the other functions are written in SWIG generated C). pydoc uses __all__ if it's defined, but it isn't for the Python part of the interface. When using -builtin there is a __all__ for the C extension but not for the Python wrapper. I'm not sure I can safely add use_python_logging to it without breaking something else.

MikeTough commented 6 years ago

Hi Jim,

Many thanks for your rapid reply. This was just the info I was after :) I've now got the logging just the way I want.

Best Regards

Mike

On 5 August 2018 at 18:16, Jim Easterbrook notifications@github.com wrote:

The mapping is the only parameter to use_python_logging. The logging should be sent to a 'gphoto2' logger (see line 194 of the source file port_log.i). https://github.com/jim-easterbrook/python-gphoto2/ blob/master/src/gphoto2/port_log.i#L178

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jim-easterbrook/python-gphoto2/issues/60#issuecomment-410534307, or mute the thread https://github.com/notifications/unsubscribe-auth/AelPtO1ml6o6WDbMDiiBnyMbJQOTz1LEks5uNyh9gaJpZM4Vva7I .