Uploaded image for project: 'Near Realtime RAN Intelligent Controller'
  1. Near Realtime RAN Intelligent Controller
  2. RIC-38

python logging library does not respect pylint "lazy logging"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low
    • None
    • None
    • None
    • None

      Hi

      The python logging module "mdclogpy" does not respect the standard python logging interface

                mdc_logger.debug("Pre-send summary: %s, Post-send summary: %s", pre_send_summary, post_send_summary)
             TypeError: debug() takes 2 positional arguments but 4 were given

      Python example: 

           >>> logger = logging.Logger(_name_)
           >>> a = "asdf"
           >>> logger.debug("%s", a)

      Pylint will complain if you use string formatting for logging because %s is preferred because it does some kind of lazy evaluation. If you make the above code

         logger.debug("foo {}".format(a))

      Pylint will complain:

           logging-format-interpolation: Use % formatting in logging functions and pass the % parameters as arguments
       

       Relevant python docs: https://docs.python.org/3/howto/logging.html#optimization

       

      To note, the reason I raise this is not to nitpick, but because for a python application to transition to this library, if the python app uses proper logs with % already (like A1), all those code statements blow up after dropping in mdclogger.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            riska Roni Riska
            tommycarpenter Tommy Carpenter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: