Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Add log to Qt source code
Forum Updated to NodeBB v4.3 + New Features

Add log to Qt source code

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 3 Posters 505 Views 2 Watching
  • 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.
  • X Offline
    X Offline
    xixi_cly
    wrote on last edited by
    #1

    I have a embedded device,but the keyboard can't be used.So I want to add some log to the source code in the libinput keyboard module.However, after cross compiling the source code, the log is not printed.
    Then, I used export QT_LOGGING_RULES="*.debug=true" in my embedded device, there is also nothing printed.
    I want to know how to print the log I wanted.
    The source code patch as this:

    diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp
    index 733cf7d..fc78870 100644
    --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp
    +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp
    @@ -49,6 +49,9 @@
     #include <QtCore/private/qcore_unix_p.h>
     #include <private/qguiapplication_p.h>
     #include <private/qinputdevicemanager_p_p.h>
    +#include <QDebug>
    +#include <cstdlib>
    +#include <stdio.h>
    
     QT_BEGIN_NAMESPACE
    
    @@ -87,6 +90,11 @@ static void liLogHandler(libinput *libinput, libinput_log_priority priority, con
    
     QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec)
     {
    +    system("cd /");
    +    system("mkdir test1");
    +    qDebug("test1");
    +    printf("printf test1\n");
    +    qFatal("fatal test1");
         Q_UNUSED(key);
         Q_UNUSED(spec);
    
    diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
    index 3722c1c..488cb94 100644
    --- a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
    +++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
    @@ -44,6 +44,9 @@
     #include <QtGui/private/qinputdevicemanager_p.h>
     #include <qpa/qwindowsysteminterface.h>
     #include <libinput.h>
    +#include <cstdlib>
    +#include <QDebug>
    +#include <stdio.h>
     #ifndef QT_NO_XKBCOMMON_EVDEV
     #include <xkbcommon/xkbcommon-keysyms.h>
     #include <xkbcommon/xkbcommon-names.h>
    @@ -138,6 +141,11 @@ QLibInputKeyboard::QLibInputKeyboard()
           m_state(0)
     #endif
     {
    +    system("cd /");
    +    system("ls > test");
    +    qDebug("test2");
    +    printf("printf test2\n");
    +    qCWarning(qLcLibInput) << "qcwarning test2";
     #ifndef QT_NO_XKBCOMMON_EVDEV
         qCDebug(qLcLibInput) << "Using xkbcommon for key mapping";
         m_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
    @@ -181,11 +189,15 @@ QLibInputKeyboard::~QLibInputKeyboard()
    
     void QLibInputKeyboard::processKey(libinput_event_keyboard *e)
     {
    +    system("cd /");
    +    system("mkdir test3");
     #ifndef QT_NO_XKBCOMMON_EVDEV
         if (!m_ctx || !m_keymap || !m_state)
             return;
    
         const uint32_t k = libinput_event_keyboard_get_key(e) + 8;
    +    qDebug() << "k = " << k;
    +    qCWarning(qLcLibInput) << "k = " << k;
         const bool pressed = libinput_event_keyboard_get_key_state(e) == LIBINPUT_KEY_STATE_PRESSED;
    
         QVarLengthArray<char, 32> chars(32);
    @@ -202,7 +214,8 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e)
         // including the current key in case it is a modifier.
         Qt::KeyboardModifiers mods = Qt::NoModifier;
         const int qtkey = keysymToQtKey(sym, &mods, text);
    -
    +    qDebug() << "qtkey = " << qtkey;
    +     qCWarning(qLcLibInput) << "qtkey = " << qtkey;
         xkb_state_component modtype = xkb_state_component(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);
         if (xkb_state_mod_index_is_active(m_state, m_modindex[0], modtype) && (qtkey != Qt::Key_Control || !pressed))
             mods |= Qt::ControlModifier;
    
    
    

    Thanks

    Pablo J. RoginaP 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you sure your custom is installed properly ?
      Are you sure it is used by your application ?
      Are you sure that its used at all ?

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

      1 Reply Last reply
      0
      • X xixi_cly

        I have a embedded device,but the keyboard can't be used.So I want to add some log to the source code in the libinput keyboard module.However, after cross compiling the source code, the log is not printed.
        Then, I used export QT_LOGGING_RULES="*.debug=true" in my embedded device, there is also nothing printed.
        I want to know how to print the log I wanted.
        The source code patch as this:

        diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp
        index 733cf7d..fc78870 100644
        --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp
        +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp
        @@ -49,6 +49,9 @@
         #include <QtCore/private/qcore_unix_p.h>
         #include <private/qguiapplication_p.h>
         #include <private/qinputdevicemanager_p_p.h>
        +#include <QDebug>
        +#include <cstdlib>
        +#include <stdio.h>
        
         QT_BEGIN_NAMESPACE
        
        @@ -87,6 +90,11 @@ static void liLogHandler(libinput *libinput, libinput_log_priority priority, con
        
         QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec)
         {
        +    system("cd /");
        +    system("mkdir test1");
        +    qDebug("test1");
        +    printf("printf test1\n");
        +    qFatal("fatal test1");
             Q_UNUSED(key);
             Q_UNUSED(spec);
        
        diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
        index 3722c1c..488cb94 100644
        --- a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
        +++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
        @@ -44,6 +44,9 @@
         #include <QtGui/private/qinputdevicemanager_p.h>
         #include <qpa/qwindowsysteminterface.h>
         #include <libinput.h>
        +#include <cstdlib>
        +#include <QDebug>
        +#include <stdio.h>
         #ifndef QT_NO_XKBCOMMON_EVDEV
         #include <xkbcommon/xkbcommon-keysyms.h>
         #include <xkbcommon/xkbcommon-names.h>
        @@ -138,6 +141,11 @@ QLibInputKeyboard::QLibInputKeyboard()
               m_state(0)
         #endif
         {
        +    system("cd /");
        +    system("ls > test");
        +    qDebug("test2");
        +    printf("printf test2\n");
        +    qCWarning(qLcLibInput) << "qcwarning test2";
         #ifndef QT_NO_XKBCOMMON_EVDEV
             qCDebug(qLcLibInput) << "Using xkbcommon for key mapping";
             m_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
        @@ -181,11 +189,15 @@ QLibInputKeyboard::~QLibInputKeyboard()
        
         void QLibInputKeyboard::processKey(libinput_event_keyboard *e)
         {
        +    system("cd /");
        +    system("mkdir test3");
         #ifndef QT_NO_XKBCOMMON_EVDEV
             if (!m_ctx || !m_keymap || !m_state)
                 return;
        
             const uint32_t k = libinput_event_keyboard_get_key(e) + 8;
        +    qDebug() << "k = " << k;
        +    qCWarning(qLcLibInput) << "k = " << k;
             const bool pressed = libinput_event_keyboard_get_key_state(e) == LIBINPUT_KEY_STATE_PRESSED;
        
             QVarLengthArray<char, 32> chars(32);
        @@ -202,7 +214,8 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e)
             // including the current key in case it is a modifier.
             Qt::KeyboardModifiers mods = Qt::NoModifier;
             const int qtkey = keysymToQtKey(sym, &mods, text);
        -
        +    qDebug() << "qtkey = " << qtkey;
        +     qCWarning(qLcLibInput) << "qtkey = " << qtkey;
             xkb_state_component modtype = xkb_state_component(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);
             if (xkb_state_mod_index_is_active(m_state, m_modindex[0], modtype) && (qtkey != Qt::Key_Control || !pressed))
                 mods |= Qt::ControlModifier;
        
        
        

        Thanks

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @xixi_cly said in Add log to Qt source code:

        src/platformsupport/input/libinput/qlibinputhandler.cpp

        One non-technical comment just in case. You might be already aware that since you're or you'll be modifying a (L)GPL licensed component (see qlibinputhandler.cpp copyright header) you'd be obliged to contribute it back... which might conflict with your application licensing schema...

        LGPL – Any modification to a Qt component covered by the GNU Lesser General Public License must be contributed back to the community. This is the primary open source Qt license, which covers the majority of Qt modules.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0

        • Login

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