duck7000 / imdbGraphQLPHP

IMDb GraphQL API PHP class
11 stars 0 forks source link

Detailed logging #74

Closed GeorgeFive closed 3 months ago

GeorgeFive commented 3 months ago

Hey, would it be possible to update graphql.php to include details on which id failed? Example, I've got a few variations of these in my error log:

[24-Aug-2024 07:11:19 EST] PHP Fatal error: Uncaught Exception: Failed to retrieve query [Name] in imdb6/src/Imdb/GraphQL.php:100 Stack trace: 0 imdb6/src/Imdb/GraphQL.php(61): Imdb\GraphQL->doRequest('query Name($id:...', 'Name', Array) 1 imdb6/src/Imdb/Name.php(92): Imdb\GraphQL->query('query Name($id:...', 'Name', Array) 2 cron/get_cast_dates.php(22): Imdb\Name->name() 3 {main} thrown in imdb6/src/Imdb/GraphQL.php on line 100

This is not a problem with the class itself, I think imdb just didn't work in this particular instance for whatever reason, but it would be nice to know which ID it choked on so I could double check it and maybe manually refresh it if needed?

Maybe a log entry like - Uncaught Exception: Failed to retrieve query [Name] in nm0123456

duck7000 commented 3 months ago

I'll try to add id to Uncaught Exception

Do you want this added to logger as well?

duck7000 commented 3 months ago

@GeorgeFive I added id to Exception, could you test if this works?

GeorgeFive commented 3 months ago

I'll keep an eye on the log and let you know how it works. It happens randomly, so I can't force a test on it, just have to wait and see. Sometimes [name], sometimes [data], sometimes 5-10 a day, sometimes none. Thanks!

GeorgeFive commented 3 months ago

PHP Fatal error: Uncaught Exception: Failed to retrieve query [Name] , IMDb id [nm0411150]

Looks good, thanks!

duck7000 commented 3 months ago

Nice, now we have to find out what went wrong? If i test this id it works fine

It might be too many connections in a time, IMDb does throttle requests, although i didn't experience this jet. My use case is different of course

GeorgeFive commented 3 months ago

I'm pretty sure it wasn't the class, just imdb giving an error. I store all names in my database with a date_checked field, then run a cron to grab the oldest checked names and rescan them for updated pics and info. I do sleep() in between names, but I guess sometimes it chokes anyway.

duck7000 commented 3 months ago

Ah that make sence, so this one can be closed