Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rolling logfile when starting if needed #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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();
    }

@xiaobingcaicai
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();
    }

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