adixon / ca.civicrm.logviewer

CiviCRM Log Viewer
Other
9 stars 11 forks source link

Fix for localized dates (month names with unicode) #10

Closed mlutfy closed 2 years ago

mlutfy commented 2 years ago

A partner noticed that the log was empty and thought it was a file permission issue, because when there are no entries, logviewer displays "Unable to read entries from logfile at ..".

The bug was instead that logviewer has a regexp for detecting dates, but the site's default language is in French, so the logs have entries such as fév 14 12:51:13.

To reproduce:

This PR makes sure that unicode is used in the relevant string functions.

adixon commented 2 years ago

Ah very nice!

I notice that I put this in the readme "It might break in other languages and/or non-default time/date formats, since it relies on regular expressions for parsing the log output.". It looks like you're solving that problem for some kinds of localization, though I suspect it may still break for non-european languages or maybe even european languages that put the date/time bits in a different order.

Happy to pull this in for now and test on my various sites, it's definitely an improvement.

It also reminds me that whatever is generating the log file is relying on an interesting date/time - I often see the time jump around to correspond presumably with the visitors timezone, instead of using a standardized (or even qualified) timezone.

mlutfy commented 2 years ago

Great, thanks!

It works for Turkish and Russian, but not Arabic/Chinese/etc. And I agree, the log format is odd, I think it's the default from PEAR Log. I'm a bit afraid to open that can of worms :)

adixon commented 2 years ago

Yes, I'm all for letting sleeping worms lie.