Forum

Thread tagged as: Question, Error, Api

Error logging handler

Is there a nice error logging function in Perch that we can use?

For example, in Drupal there is watchdog() which logs to it's internal DB tables, and has a UI to read this. Whilst the UI isn't possible, logging these things, either to the DB or /var/logs/perch would be handy, so wanted to check:

  1. Whether this is possible out of the box
  2. If not possible out of the box, what recommendation might you have within Perch to do this in a sensible manner
Dan Duke

Dan Duke 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

We have an error logger - you can turn on debug: https://docs.grabaperch.com/docs/installing-perch/configuration/debug/

We don't persist it to the database, but you could use the API to create an app to do that if you needed it.

Thanks Drew, we will likely looking into the AddOn approach, as would like to use this across sites in a consistant way. It will be a monolog integration I expect, so we can configure, and push to external logging tools.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What sort of things are you looking to log?

At this point, we have a custom integration with another system which is failing randomly. So would like to log it failing, and the variables it has at that moment. But further down the road, it can be very useful to log other things such as when items are edited/deleted and who by, as well as if we add any flood testing on the login form to pick up issues before they get too serious.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, great. The event hooks should help you with that too.

Sounds great, is there documentation around this I can read at the same time? I had a quick look, but couldn't see anything obvious. https://docs.grabaperch.com/runway/

Thanks, Dan

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can find it here:

https://docs.grabaperch.com/api/events/

Also, to get the log created by PerchUtil::debug() for each page, you can do:

$Perch = Perch::fetch();
print_r($Perch->debug_items);

Perfect thanks for sharing that