pycrate icon indicating copy to clipboard operation
pycrate copied to clipboard

move various print() to a proper logging mechanism

Open p1-bmu opened this issue 3 years ago • 2 comments

Various print() exists throughout pycrate, that should be moved to a proper logging mechanism, in order to not eventually pollute stdout. All logging should be done with the log() function in ./pycrate_core/utils.py, and this log function should do a proper logging instead of just a print. This should apply to all part of the library, except the pycrate_corenet part which has already a specific handling for logs, and the tools which have to print.

Places where explicit print() should be changed to log():

  • ./pycrate_ether/IP.py

p1-bmu avatar May 21 '21 10:05 p1-bmu

Various print() exists throughout pycrate, that should be moved to a proper logging mechanism, in order to not eventually pollute stdout. All logging should be done with the log() function in ./pycrate_core/utils.py, and this log function should do a proper logging instead of just a print.

It's more work, but better to call log(...) directly in the module where the event occurs.

The reason for this is with the boilerplate (in every module):

import logging

log = logging.getLogger(__name__)

Then the log object will have a name matching the name of the module, which makes it easy to see where in the library the message was generated.

If you centralise the call, everything will look like it came from pycrate_core.utils

benmaddison avatar May 22 '21 15:05 benmaddison

Yes, I realize this while reading the logging module doc and tested it. This will require changes in many files : I'll do it when I a have proper time.

p1-bmu avatar May 25 '21 11:05 p1-bmu