qtlogger

QtLogger Documentation

QtLogger Documentation

Project Status C++ Standard Qt Version License

A simple yet powerful logging solution for the Qt Framework. QtLogger provides an intuitive and configurable logging system that works seamlessly with existing Qt logging macros (qDebug(), qInfo(), qWarning(), qCritical(), qFatal()).

Key Features


Table of Contents

Getting Started

Core Concepts

Configuration

API Reference

Advanced Topics


Quick Example

#include "qtlogger.h"

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    
    gQtLogger.configure();  // That's it!
    
    qDebug() << "It just works!";
    
    return app.exec();
}

For more complex scenarios:

#include "qtlogger.h"

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    gQtLogger
        .moveToOwnThread()                 // Asynchronous logging
        .addSeqNumber()
        .pipeline()
            .filterLevel(QtWarningMsg)     // Only warnings and above
            .formatPretty()
            .sendToStdErr(true)            // Colored output
        .end()
        .pipeline()
            .format("%{time} [%{category}] %{type}: %{message}")
            .sendToFile("app.log", 1024 * 1024, 5)
        .end();

    gQtLogger.installMessageHandler();

    qDebug() << "Application started";
    qWarning() << "This is a warning";

    return app.exec();
}

Requirements


License

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


Next
Getting Started →