Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide6 disables logging debug level
QtWS25 Last Chance

PySide6 disables logging debug level

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 3 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Strangelove
    wrote on 13 Aug 2021, 09:43 last edited by Strangelove
    #1

    I can't understand why PySide6 seems to interfere with my logging configuration. Consider this:

    import logging
    
    logging.basicConfig(level=logging.DEBUG)
    logging.debug('Hey')
    

    This outputs:

    DEBUG:root:Hey
    

    But this:

    import logging
    import PySide6
    
    logging.basicConfig(level=logging.DEBUG)
    logging.debug('Hey')
    

    Output nothing.

    The order of imports doesn't matter. Also, importing a specific module from PySide6 doesn't seem to matter either (e.g. from PySide6.QtWidgets import QAbstractButton gives the same result).

    If I use a custom logger, the debug level works but every message is displayed twice, but only if PySide6 is imported:

    import logging
    from PySide6.QtWidgets import QAbstractButton
    
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    
    ch = logging.StreamHandler()
    ch.setFormatter(logging.Formatter('[ %(levelname)s ] %(name)s : %(message)s'))
    logger.addHandler(ch)
    logger.debug('Hey')
    

    Results in:

    [ DEBUG ] __main__ : Hey
    DEBUG:__main__:Hey
    

    Remove the PySide6 import, and I only get the first message.

    Why is that happening?

    Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Aug 2021, 19:34 last edited by
      #2

      Hi,

      Which version of PySide6 are you using ?
      On which platform ?
      Which which version of Python ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 13 Aug 2021, 19:37
      0
      • S SGaist
        13 Aug 2021, 19:34

        Hi,

        Which version of PySide6 are you using ?
        On which platform ?
        Which which version of Python ?

        S Offline
        S Offline
        Strangelove
        wrote on 13 Aug 2021, 19:37 last edited by
        #3

        @SGaist Pyside 6.1.2, macOS Catalina, Python 3.9.6.

        Please have a look at my SO post for more details (in the comments). I can get around this behavior by manually removing the handler that the PySide6 import seems to add to my logger. But it feels like a hack.

        E 1 Reply Last reply 13 Aug 2021, 19:54
        0
        • S Strangelove
          13 Aug 2021, 19:37

          @SGaist Pyside 6.1.2, macOS Catalina, Python 3.9.6.

          Please have a look at my SO post for more details (in the comments). I can get around this behavior by manually removing the handler that the PySide6 import seems to add to my logger. But it feels like a hack.

          E Offline
          E Offline
          eyllanesc
          wrote on 13 Aug 2021, 19:54 last edited by eyllanesc
          #4

          @Strangelove It seems like a bug introduced in PySide6 since it is not observed in PySide2 so I recommend you report it: https://bugreports.qt.io/projects/PYSIDE/issues, here we can do little or nothing. I also reproduce that behavior on Linux with PySide6 6.1.2 and python 3.9.6.

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          S 1 Reply Last reply 13 Aug 2021, 20:10
          0
          • E eyllanesc
            13 Aug 2021, 19:54

            @Strangelove It seems like a bug introduced in PySide6 since it is not observed in PySide2 so I recommend you report it: https://bugreports.qt.io/projects/PYSIDE/issues, here we can do little or nothing. I also reproduce that behavior on Linux with PySide6 6.1.2 and python 3.9.6.

            S Offline
            S Offline
            Strangelove
            wrote on 13 Aug 2021, 20:10 last edited by
            #5

            @eyllanesc said in PySide6 disables logging debug level:

            I recommend you report it

            Just did. Thanks a lot.

            1 Reply Last reply
            0

            4/5

            13 Aug 2021, 19:54

            • Login

            • Login or register to search.
            4 out of 5
            • First post
              4/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved