nxp-mcuxpresso / pypemicro

Other
4 stars 3 forks source link

Only log info about PEMicro shared library once #5

Closed flit closed 3 years ago

flit commented 3 years ago

Pypemicro repeatedly outputs the same log message when opening the PEMicro library. This is annoying for pyocd users when it is polling for devices.

The request is that pypemicro track that it has logged info about the library, so it only logs once per process.

We should also consider using the passed-in loggers for all logging. This allows pyocd to redirect the pypemicro logging to a trace log. However, I have mixed feeling about this, since technically using its own logger is correct. Passed-in loggers are used for the JLink probe only because in that case, the logging is being done by the JLink shared lib and being redirected to a Python library by the C callback. So maybe pyocd should just set the pypemicro logger level directly?

Example log:

0001662:DEBUG:pemicro:Opened PEMicro library: c:\python38\lib\site-packages\pypemicro\libs\Windows\unitacmp-64.dll
Waiting for a debug probe to be connected...
0002351:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0002938:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0003535:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0004100:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0004696:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0005251:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0005817:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0006408:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0006981:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0007544:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0008144:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0008712:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0009316:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0009886:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0010453:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0011051:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
0011645:DEBUG:pemicro:Opened PEMicro library: unitacmp-64.dll
…
…
Gargy007 commented 3 years ago

HEllo, I understand that this DEBUG log is little bit annoying, but is in DEBUG mode! and there are some annoying lines. In fact you can see home many times the library has been openned.

At the moment I'm keeping this line as is, hopes that you understand. Petr