[Logwatch-Devel] Bug in applystddate (with different LOCALE)

Kristian H. Resset kristian at resset.no
Sat Jan 14 10:02:10 MST 2006


Logwatch version: Latest stable: 7.1.1
/usr/share/logwatch/scripts/shared/applystddate

Description:
TimeFilter('%b %e %H:%M:%S') returns the date according to the server's
LOCALE settings. For some locales, that means that month names are
returned without capitals (jan, feb, mar, etc...) whereas the log files
like maillog and messages contains dates with capitalized month
abbreviations. In addition, month name abbreviations will vary between the
locales, as well as weekdays abbrevs, which you have hard coded in English
(line 30 of same script).

In my particular case I discovered this because I have the server set to
Norwegian locale, which returns lower case abbrevs (jan, feb, mar, etc.).

As an example would calling the local data function on May 13, 2006
produce "lau mai 14" with my locale instead of the expected "Sat May 14"
on an English locale.

My preliminary solution:
Simply making the regexp in line 28 of applystddate case insensitive did
the trick, and my logwatch installation now processes all my logfiles
correctly. This works as long as the month abbrev itself is the same as in
English.

New line 28 in my applystddate file, simply added an 'i' as regexp parameter:
if ($ThisLine =~ m/^$SearchDate /oi) {

Suggestion on permanent solution:
In my particular case, I don't need for logwatch to process log files with
weekday as part of the timestamp, so the preliminary solutions will work
fine for me until May, when the first difference in month abbrev name will
occur.
My suggestion would be that you force the time/date function to push an
en_GB or en_US LOCALE into $SearchDate, since very few will have set their
daemons to log in locale date format. Additionally, you could mention that
log timestamps must be in standard English format in the documentation as
well.
You might of course also consider to do the regexp searches case
insensitive for the sake of reducing problems with custom log formats
where lower case weekday/month names are used.

I hope this was helpful. Keep up the good work with this wonderful tool!

Regards from Norway,
Kristian H. Resset


More information about the Logwatch-Devel mailing list