Jump to content

Recommended Posts

Posted

We have logging of almost every page request like this:

$log->save('userdb_log', $message);
$log->prune('userdb_log', 30);

The problem is, that the file is not saved for 30 days, but only for a few minutes.

There is this error found regarding this:

unlink: Given filename is not a file or link: /site/assets/logs/userdb_log.txt

And then:

rename: Given pathname ($oldName) that does not exist: /site/assets/logs/userdb_log.txt.new

Is it not ok to try to prune the file just after the save every time? Where should the pruning then happen?

  • 2 weeks later...
Posted

Pruning is kind of an expensive operation as it involves finding existing log entries, exporting them to a new file, then deleting the old file, then renaming the new file to the old filename. I'd avoid doing it every time you save a log entry. I prefer to manually prune from the admin. The error messages seem to indicate that maybe the prune is colliding with the save. Likely pruning immediately after saving is happening in the same timestamp and not giving it a chance to consistently save a log entry. So at the least, I would disconnect your prune() operation from your save() operation, perhaps moving your prune operation into a LazyCron::everyDay hook.

  • Like 2
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...