Hi,
I am using a python
parser for parsing the incoming message from syslog-ng. In my log messages
some fields are optional and some are not.I want to know how to handle these
optional parameters in the python regual expression.
for
example:
sample log
:->
log='Sep 15 22:23:37 ecis007 codeSystemName=5
UserID="Admin"'
regular expression
:->
aregex=re.compile(r"(?P<destmonth>\S+) (?P<devicedate>\S+)
(?P<devtime>\S+) (?P<devicename>\S+)
codeSystemName=(?P<EventIDcodeSystemName>.*)")
if I run the
following python command then i can get all the
parameters
r=aregex.match(log2)
but
if
"codeSystemName=5" is a optional parameters and it is not in some messages then
my parser is not able to parse the message.
log='Sep 15 22:23:37 ecis007
UserID="Admin'
let me know how to
write the regex for optional parameters ?
Regards,
Vaibhav