opcodesio / log-viewer

Fast and beautiful Log Viewer for Laravel
https://log-viewer.opcodes.io
MIT License
3.49k stars 250 forks source link

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

Closed lparede closed 6 months ago

lparede commented 6 months ago

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?

arukompas commented 6 months ago

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 🤔

lparede commented 6 months ago

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.

lparede commented 6 months ago

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

arukompas commented 6 months ago

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.

lparede commented 6 months ago

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.