Skip to content

Conversation

@pnlarsson
Copy link

The rolling is working if the application is not shutdown over night (for daily).

Solved by getting the modification time from file if it exists when starting the application and using it instead of now.

@cyberbobs
Copy link
Member

Sorry, but I don't actually understand, what is happening in the changes you submitted. Could you please describe, why must we use the currently opened log file last modification date and time instead of current date? The modification datetime will be anyway updated to meet the current datetime after writing the log record once :)

@pnlarsson
Copy link
Author

If you use daily and stop app in the night and start it in the morning - it didn't roll the logs.

@raccoonmonk
Copy link

I need this change, it's very useful. But still your commit has a problem - the last append goes to the old logfile.

@LeeGaning
Copy link

I need this change, it's very useful. But still your commit has a problem - the last append goes to the old logfile.
this will be work.

    QDateTime now;
    if (m_rollOverTime.isNull()) {
        QFileInfo fileInfo = QFileInfo(fileName());
        if (fileInfo.isFile()) {
            now = fileInfo.lastModified();
        }
    }
    if (!now.isValid() || now > QDateTime::currentDateTime()) {
        now = QDateTime::currentDateTime();
    }

@howhuai
Copy link

howhuai commented Oct 11, 2024

I need this change, it's very useful. But still your commit has a problem - the last append goes to the old logfile.
this will be work.

    QDateTime now;
    if (m_rollOverTime.isNull()) {
        QFileInfo fileInfo = QFileInfo(fileName());
        if (fileInfo.isFile()) {
            now = fileInfo.lastModified();
        }
    }
    if (!now.isValid() || now > QDateTime::currentDateTime()) {
        now = QDateTime::currentDateTime();
    }

thanks, it works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants