I don't think that we need to get into a big discussion in the context of this thread.
Part of what I'm saying is that with:
[2012/02/16 00:08:34] [29] ERRORMSG unknown error
There is no reason or need to parse the date time format with some huge regex eg:
m/\[(\d{4}\/\d{2}\/\d{2}\s+\d{2}\:\d{2}\:\d{2})\]\s+\[(\d{1,3})\]
If the line begins with "[" it is a date/time and there is no reason to parse or otherwise try to understand it. Maybe this changes to YYYY-MM-DD or YYYY.MM.DD instead of YYYY/MM/DD? In the context of this re-formatting program, it shouldn't matter.
Basically, if a complex regex is not essential to the program operation, don't even do that. Here all that is needed is to understand that the square brackets on the first part of a line signifies a "new record". Past that, the parser shouldn't care about the format between the square brackets, because it doesn't need to do that in order to do its job!
Maybe we are actually in agreement here? ^[...] starts a new "message line" and that is all we need to know - that is considered "valid input" no matter what is between the [...]. |