Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging #331

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Add logging #331

wants to merge 19 commits into from

Commits on Jan 5, 2024

  1. Add simple logging utility

    Partially inspired by rfc5424, along with a few other idioms I picked up
    along the way.  This should allow one to tweak the log level by setting
    a minimum log level in the `Log' namespace.  Right now I've set the log
    level to debug in the main entry point.
    psyomn committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    ff34267 View commit details
    Browse the repository at this point in the history

Commits on Jan 7, 2024

  1. Configuration menu
    Copy the full SHA
    d7d9ba2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    933c675 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e436cb5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bd117d8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5a33e41 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ab56bc3 View commit details
    Browse the repository at this point in the history
  7. Show logs in infodialog's edit box

    Users should be able to copy the logs from the infodialog box, along
    with version information for slightly easier troubleshooting.
    psyomn committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    26cf888 View commit details
    Browse the repository at this point in the history
  8. Add fmt for Linux CI/CD build

    psyomn committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    34f0088 View commit details
    Browse the repository at this point in the history
  9. Add fmt for macOS CI/CD build

    psyomn committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    e72a569 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    64307ad View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    3ce38cb View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    2ca68d1 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    5ba2a3d View commit details
    Browse the repository at this point in the history
  14. Replace use of std::format with fmt:format in logger

    I'm leaving this commit here instead of squashing, so that in the
    future, we could technically just reverse this commit.
    psyomn committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    f5da24a View commit details
    Browse the repository at this point in the history
  15. Implement poorman's log rotating

    This implements a very simple circular buffer that will take the last N
    lines in a log file, and keep those instead.  Right now the maximum N is
    hardcoded, but the code is written in a fashion that we can revisit some
    of this, and add toggles where we see fit (for example in a settings
    dialog or so).
    
    I tested out the functionality this way:
    
            $ yes some-log-line | nl | head -5000 > log.txt
    
    And then running PTE2 with a max log size of 1000, I noticed the logfile
    like so:
    
            $ head -10 log.txt
            4001  some-log-line
            4002  some-log-line
            4003  some-log-line
            4004  some-log-line
            4005  some-log-line
            4006  some-log-line
            4007  some-log-line
            4008  some-log-line
            4009  some-log-line
            4010  some-log-line
    
    and the bottom:
    
            $ tail -10 log.txt
            2023-12-30T14:38:32Z: [debug]: finding translations for locale:
            2023-12-30T14:38:32Z: [debug]:   locale: en-US
            2023-12-30T14:38:32Z: [debug]:   locale: en
            2023-12-30T14:38:32Z: [debug]:   locale: en-Latn-US
            2023-12-30T14:38:32Z: [debug]:   - checking: /home/psyomn/.local/share/powertab/powertabeditor/translations
            2023-12-30T14:38:32Z: [debug]:   - checking: /usr/local/share/powertab/powertabeditor/translations
            2023-12-30T14:38:32Z: [debug]:   - checking: /usr/share/powertab/powertabeditor/translations
            2023-12-30T14:38:32Z: [debug]:   - checking: /home/psyomn/programming/cc/fork/powertabeditor/build/bin/data/translations
            2023-12-30T14:38:32Z: [debug]:   - checking: /usr/share/qt/translations
            2023-12-30T14:38:32Z: [debug]: loaded qt base translations from /usr/share/qt/translations/qtbase_en.qm
    
    and last checks:
    
            $ nl log.txt | head -1
                 1    4001  some-log-line
            $ nl log.txt | tail -1
              1011  2023-12-30T14:38:32Z: [debug]: loaded qt base translations from /usr/share/qt/translations/qtbase_en.qm
    psyomn committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    b69149b View commit details
    Browse the repository at this point in the history
  16. Add format wrapper for QString

    This adds a custom format wrapper for QString objects, so that they can
    be logged directly.
    psyomn committed Jan 7, 2024
    Configuration menu
    Copy the full SHA
    aabde63 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    5bb4293 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    e11f0b4 View commit details
    Browse the repository at this point in the history