From 3eaa939bf40c42228ec5dcffea23c4f4f8af7acc Mon Sep 17 00:00:00 2001 From: Joshua Kugler Date: Fri, 8 Jul 2011 20:20:04 -0800 Subject: [PATCH] Added option to use new friendly names, will not break backward compatibility --- apachelog.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apachelog.py b/apachelog.py index 9f7c203..f6724f0 100755 --- a/apachelog.py +++ b/apachelog.py @@ -196,7 +196,7 @@ class parser: '%O':'bytes_sent', } - def __init__(self, format): + def __init__(self, format, use_names=False): """ Takes the log format from an Apache configuration file. @@ -209,6 +209,7 @@ class parser: self._names = [] self._regex = None self._pattern = '' + self._use_names = use_names self._parse_format(format) def _parse_format(self, format): @@ -240,7 +241,10 @@ class parser: element = lstripquotes.sub('', element) element = rstripquotes.sub('', element) - self._names.append(self.alias(element)) + if self._use_names: + self._names.append(self.alias(element)) + else: + self._names.append(element) subpattern = '(\S*)' -- 2.26.2