Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Problem with installCustomFormatSpecifier. #844

@Kuzma30

Description

@Kuzma30

I use such setup flow:


    QString filePath = ":/qml/test_conf.conf";

    QFile file(filePath);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "Не вдалося відкрити файл для читання";
        return false;
    }

    QTextStream in(&file);
    QString fileContent = in.readAll();

    file.close();
    // Load configuration from file
    el::Configurations conf;
    conf.setToDefault();
    el::Helpers::installCustomFormatSpecifier(el::CustomFormatSpecifier("%session", getSession));  //programm run session
    conf.parseFromText(fileContent.toStdString());

    // Reconfigure single logger
    el::Loggers::reconfigureLogger("default", conf);
    // Actually reconfigure all loggers instead
    el::Loggers::reconfigureAllLoggers(conf);
    // Now all the loggers will use configuration from file
 
const char* getSession(const el::LogMessage*) {
    return "1";
}

test_conf.conf


* GLOBAL:
    FORMAT = %datetime{%h:%m:%s,%g} %level %session: %msg
    FILENAME = /tmp/logs/Ferti.%datetime{%Y%M%d}_%session.log
    ENABLED  = true
    TO_FILE  = true
    TO_STANDARD_OUTPUT  = true
    SUBSECOND_PRECISION = 6
    PERFORMANCE_TRACKING = false
    MAX_LOG_FILE_SIZE = 2097152 ## 2MB

Its work for LOG, but not work for FILENAME
Example:
05:34:17,071665 INFO 1: Program Started
It create /tmp/logs/Ferti.20231011_%session.log not /tmp/logs/Ferti.20231011_1.log

I need separate log file for new program run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions