opcodesio/log-viewer

Request failed with status code 500: Undefined array key 1 error when searching

lparede opened this issue · 5 comments

Hello.

When searching in a certain log file for a specific term, sometimes I get the following messages: Request failed with status code 500: Undefined array key 1

Using the browser inspector, I can see that the problem is in the following file:
image

It seems that in somes cases, index 1 of array variable $matches is not defined. If I make a eval of $matches[1], then the errors occurs in $matches[7].

image

Anyone with the same problem? Can I make pull request to solve this?

Hey!

Match at index 1 should be the date time. Is there a reason why a log entry does not have a datetime?

Perhaps you can share the log file (in full) with which I can reproduce the bug? Just seems weird 🤔

Yes, it's very weird. All the log entries have timestamp.

Unfortunately, I cannot share the log file, but you gave me a hint of debug.

Please hold the pull request that I made.

So, after another debug, I noticed that the log file has records without timestamps.

This is a custom log file. I will have to find out why this problems occurs.

OK
image

Not OK
image

Hey @lparede

Nice, you're in the right path!

Check what the surrounding content is inside the log file itself, not just what the log viewer shows.

It could be that one of the logs contains something that looks similar to a log structure and Log Viewer thinks it's a new entry.

That's why sharing even an excerpt of the log file can be helpful in debugging.

Problem solved!

Somehow the custom log file got some corrupted data. I used a third party package to log the user activity, but I made my own middleware to do that and now the log files are ok.