Git Product home page Git Product logo

qspdlog's Introduction

QSpdLog

QSpdLog

GitHub Workflow Status Coverage

This repository contains the source code of a library, which provides a Qt widget for displaying log messages coming from the spdlog library.

Features

  • Display log messages in a tree view
  • Display an icon for each log level
  • Separate message structure from message content
  • Search in messages
    • via regular expressions
    • use match case option
    • reuse search history
  • Auto scrolling feature with various options
    • disabled
    • scroll to the bottom when a new message is added
    • scroll to the bottom when a new message is added unless the user scrolled up
  • many more to come
  • request or suggest new ones

Usage

In its initial implementation only CMake tool is considered. To use the library in your project, you have:

  1. Add the library as a submodule (or any kind of folder in your machine)

    git submodule add https://github.com/arsdever/qspdlog.git
  2. Add the library to your CMake project

    add_subdirectory(qspdlog)
  3. Add the library to your target

    target_link_libraries(${PROJECT_NAME} qspdlog::lib)
  4. Include the interface header into the source file where you want to instantiate the widget

    #include <qspdlog/qspdlog.h>
  5. Instantiate the widget, register loggers and show the widget

    QSpdLogWidget* widget = new QSpdLogWidget();
    
    auto sink = widget->sink();
    // register the sink to whatever logger you want
    
    widget->show();

A complete example can be found in the sample folder.

Note: In the sample it's considered that you already added the library as a submodule.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • spdlog for the logging library
  • Qt for the GUI framework

Projects using QSpdLog

qspdlog's People

Contributors

arsdever avatar overflwn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qspdlog's Issues

Split tests

The tests are all packed into one single executable. The more code is written, the more the single executable grows.

Find a way of breaking down the test executable into multiple compile units (AKA cpp files) or executables.

BUILD_COVERAGE doesn't work out-of-the box on Ubuntu 22.10 with gcc 12.2.0

I'm running Ubuntu 22.10 with qt6-base and libspdlog-dev installed, running cmake .. -DBUILD_TESTING=ON -DBUILD_COVERAGE=ON runs fine, but running make afterwards (gcc version 12.2.0 (Ubuntu 12.2.0-3ubuntu1) ) returns

[  0%] Built target qspdlog_interface
[  5%] Automatic MOC and UIC for target qspdlog_lib
[  5%] Built target qspdlog_lib_autogen
[ 11%] Automatic RCC for qspdlog_resources.qrc
[ 16%] Building CXX object src/CMakeFiles/qspdlog_lib.dir/qspdlog_lib_autogen/mocs_compilation.cpp.o
c++: error: unrecognized command-line option ‘-fprofile-instr-generate’; did you mean ‘-fprofile-generate’?
c++: error: unrecognized command-line option ‘-fcoverage-mapping’
make[2]: *** [src/CMakeFiles/qspdlog_lib.dir/build.make:88: src/CMakeFiles/qspdlog_lib.dir/qspdlog_lib_autogen/mocs_compilation.cpp.o] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:182: src/CMakeFiles/qspdlog_lib.dir/all] Fehler 2
make: *** [Makefile:101: all] Fehler 2

Originally posted by @Overflwn in #32 (comment)

Per PR dockerimage build

Description

Docker images are build with every PR and pushed with tag latest. It may bring issues when having multiple PRs in parallel running the workflow. It's required to fix this:

  • docker images are pushed with different tags per PR
  • the intermediate tags should be configured to auto-remove when the PR gets merged
  • The PR should run on the corresponding image

Ability to set a style to the logger

The functionality will allow the user to assign a style to the logger, so the log messages from that particular logger will show up in a user-defined way. For example, with a red background and green foreground colors.

Check out the second table at Qt::ItemDataRole's documentation.

`QSpdLog` should not allow changing essential properties

Description

As QSpdLog is a subclass of QTreeView and it derives publicly, it also derives the interface of the QTreeView, allowing the users to do dangerous things to its instance (e.g. changing the model).

Possible solutions

The class should derive from the QWidget class and have the QTreeView widget in it.

Setup code coverage report

Description

To keep the code quality on high levels, an automated code coverage report should be configured.

Display a column for the individual logger names (+ hide columns?)

In case of multiple loggers writing to the same sink(s) it's hard to differentiate which logger sent which message.

Personally, in projects where I have multiple threads for example, I like to create separate loggers writing to the same sinks so that I can quickly see which thread / "part of the system" logged what into the sinks without explicitly writing that into the log messages themselves.

I think simply adding a column for the logger names would be sufficient enough for this. I can add this and create a pull request for it, if you want to. As far as I can understand the code it's a very simple addition.

Maybe even adding a feature to hide specific columns would be a good idea as well? I'm not sure about that though.

`Qt` message logging may be tricky

If you handle the Qt messages to print those in the widget, the widget may report a Qt message internally while adding an entry, thus blocking the application execution. We need to somehow block all the Qt messages from the widget.

`QSpdLog` should provide infrastructure for custom toolbars

Description

As of now, the filtering and auto-scroll policy setup is done privately, by the toolbar widget which is provided by QSpdLog class. But as a user, one would want to construct their own toolbar and set it up.

Either the class should provide a way of registering their toolbar, or it should provide ways to call the required methods.

The functionality required for custom implementation is the following:

  • filter (with options of case sensitivity, regular expression)
  • auto-scroll

Possible solutions are:

  • with the interface approach
    1. create a base interface class (e.g. QAbstractSpdLogToolBar)
    2. derive the default QSpdLogToolBar from it
    3. add a method in QSpdLog for registering a QAbstractSpdLogToolBar
  • with methods exposure approach
    1. make the filter slot function public
    2. make the auto-scroll configuration setup slot function public

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.