Created
December 15, 2016 08:07
-
-
Save Makistos/e5d90f8679a9f3b62c9ee6d599833b3c to your computer and use it in GitHub Desktop.
Remove timestamps and process numbers from Android (both kernel and logcat). This makes it easier to compare logs in e.g. Beyond Compare. #perl #android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Clean up Android logs so that they are easier to compare. | |
while(<>) | |
{ | |
if (m/^\[/) { | |
# Captured from UART | |
if (m/^\[.+\]\s\d\d-\d\d/) { | |
# Logcat | |
$_ =~ s/^\[.+\]\s\d\d-\d\d\s(\d\d:*){3}\.\d{3}\s+\d+\s+\d+\s(.+)/$2/; | |
} else { | |
# Kernel | |
$_ =~ s/^(\[.+\])*\s(\[.+\])\s+(.+)/$3/; | |
} | |
} elsif (m/(\d\d:*){3}\.\d{3}\s\<\d\>/) { | |
# Kernel | |
$_ =~ s/^((\d\d:*){3}\.\d{3}\s)(\<\d\>)(\[\d+\.\d+\])*\s*(.+)/$5/; | |
} else { | |
# Logcat | |
$_ =~ s/^((\d\d:*){3}\.\d{3})\s(.+)\(\s*\d+\)(.+)/$3 $4/; | |
} | |
print; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment