ldap/admin/src/scripts/ds-logpipe.py | 3 ++-
ldap/admin/src/scripts/logregex.py | 16 ++++------------
2 files changed, 6 insertions(+), 13 deletions(-)
New commits:
commit 3c2d82e345522ae0eb349759a96b01e5efe9eff1
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jan 31 19:08:40 2011 -0700
Bug 667935 - DS pipe log script's logregex.py plugin is not redirecting the log
output to the text file
https://bugzilla.redhat.com/show_bug.cgi?id=667935
Resolves: bug 667935
Bug Description: DS pipe log script's logregex.py plugin is not redirecting the
log output to the text file
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: The logregex plugin function is really just a thin wrapper
around the builtin plugin - the only difference is that logregex will only
store those lines that match the given regexes. The fix is to just remove
the post function, and make the plugin just call the main plugin function
with the line if it matches the regexes. The only tricky part is that we
have to increment total lines in the logregex plugin and decrement it when
we call the main pluginfunction, in order to keep an accurate count of the
total number of lines read. I also cleaned up an error message and made
the print out flush.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/admin/src/scripts/ds-logpipe.py b/ldap/admin/src/scripts/ds-logpipe.py
index 5c60557..4a6053f 100644
--- a/ldap/admin/src/scripts/ds-logpipe.py
+++ b/ldap/admin/src/scripts/ds-logpipe.py
@@ -30,6 +30,7 @@ def printbuffer():
sys.stdout.writelines(buffer)
print "Read %d total lines" % totallines
print logfname, "=" * 60
+ sys.stdout.flush()
def defaultpost(): printbuffer()
@@ -179,7 +180,7 @@ def read_and_process_line(logf, plgfuncs):
if line: # read something
for plgfunc in plgfuncs:
if not plgfunc(line):
- print "Aborting processing due to function %s" % str(plgfunc)
+ print "Aborting processing due to function %s.%s" %
(plgfunc.__module__, plgfunc.__name__)
finish()
done = True
break
diff --git a/ldap/admin/src/scripts/logregex.py b/ldap/admin/src/scripts/logregex.py
index ac32922..7537953 100644
--- a/ldap/admin/src/scripts/logregex.py
+++ b/ldap/admin/src/scripts/logregex.py
@@ -5,7 +5,6 @@ import __main__ # to use globals
# supports more than one regex - multiple regex are combined using AND logic
# OR logic is easily supported with the '|' regex modifier
regex_regex_ary = []
-buffer = []
def pre(plgargs):
global regex_regex_ary
@@ -19,18 +18,11 @@ def pre(plgargs):
regex_regex_ary.append(re.compile(regexary))
return True
-def post():
- global buffer
- sys.stdout.writelines(buffer)
- buffer = []
-
def plugin(line):
- global buffer
+ __main__.totallines = __main__.totallines + 1
for rx in regex_regex_ary:
if not rx.search(line):
- break # must match all regex
+ return True # regex did not match - get next line
else: # all regexes matched
- buffer.append(line)
- if len(buffer) > __main__.maxlines:
- del buffer[0]
- return True
+ __main__.totallines = __main__.totallines - 1
+ return __main__.defaultplugin(line)