Skip to content

Instantly share code, notes, and snippets.

@fanyang89
Last active March 18, 2024 02:12
Show Gist options
  • Save fanyang89/e044b4b5bc4ad97df59787788198f9b9 to your computer and use it in GitHub Desktop.
Save fanyang89/e044b4b5bc4ad97df59787788198f9b9 to your computer and use it in GitHub Desktop.
ZooKeeper log filter
import glob
import in_place
def main():
log_paths = glob.glob("**/zookeeper*log*", recursive=True)
for path in log_paths:
print(f"processing log file {path}")
with in_place.InPlace(path) as fp:
for line in fp:
if "- Stat command output" in line:
continue
if "- Processing stat command from " in line:
continue
if "- Processing ruok command from" in line:
continue
fp.write(line)
print(f"processing log file {path} done")
if __name__ == "__main__":
main()
@fanyang89
Copy link
Author

python3 -m pip install in_place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment