Skip to content

Rolling logfile when starting if needed#12

Open
pnlarsson wants to merge 1 commit into
dept2:masterfrom
pnlarsson:master
Open

Rolling logfile when starting if needed#12
pnlarsson wants to merge 1 commit into
dept2:masterfrom
pnlarsson:master

Conversation

@pnlarsson

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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

howhuai commented Oct 11, 2024

Copy link
Copy Markdown

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