Created
January 15, 2019 02:05
-
-
Save orange-kao/6ffc2b0ae8fc0bebc469fe3bb150a018 to your computer and use it in GitHub Desktop.
Ruby script to filter debug log for linux_libnfc-nci issue 80
This file contains 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/env ruby | |
# encoding: utf-8 | |
RED = "\e[37;41;01m" | |
GREEN = "\e[37;42;01m" | |
BLUE = "\e[37;44;01m" | |
YELLOW = "\e[30;43;01m" | |
NO_COLOUR = "\e[0m" | |
def on_the_list?(line) | |
# Return | |
# true: on the white list | |
# false: on the black list AND not on the white list | |
# nil: not on any list | |
white_list = [] | |
white_list.push "Waiting for a Tag/Device..." | |
white_list.push "Device Found" | |
white_list.push "NDEF Message Received" | |
white_list.push "TNF Media" | |
white_list.push "Type :" | |
white_list.push "Data :" | |
white_list.push "bytes of NDEF data received" | |
white_list.push "D2 07 05 78 79 7A 2F 31 32 33 61 62 63 64 65" | |
white_list.push "Device Lost" | |
white_list.push "Leaving ..." | |
white_list.push "Push successful" | |
white_list.push "Push Failed" | |
black_list = [] | |
black_list.push /\AChecking response/ | |
black_list.push /\ANxp[a-zA-Z]+:/ | |
black_list.push /\ANfcAdaptation/ | |
black_list.push /\APN54X/ | |
black_list.push /\AnativeNfc/ | |
black_list.push /\AnfaSnep/ | |
black_list.push /\Awrite successful status/ | |
black_list.push /\AnfaConnectionCallback:/ | |
black_list.push /\AnfaDeviceManagementCallback:/ | |
black_list.push /\ANFA_TRANS_DM_RF_FIELD_EVT/ | |
black_list.push /\ARoutingManager::/ | |
black_list.push /\AnotifyPollingEventwhileNfcOff:/ | |
black_list.push /\AcheckforTranscation:/ | |
black_list.push /\AnativeNfcSnep_abortClientWaits/ | |
black_list.push /\AndefHandlerCallback:/ | |
black_list.push /\AnfaConnectionCallback:/ | |
white_list.each{|item| | |
if String === item && line.index(item) != nil | |
return true | |
elsif Regexp === item && item.match(line) != nil | |
return true | |
end | |
} | |
black_list.each{|item| | |
if String === item && line.index(item) != nil | |
return false | |
elsif Regexp === item && item.match(line) != nil | |
return false | |
end | |
} | |
return nil | |
end | |
if ARGV.size == 0 | |
$stdout.puts "Syntax: #{$PROGRAM_NAME} files..." | |
end | |
ARGV.each{|filename| | |
content = nil | |
File.open(filename, "rb"){|file| | |
content = file.read() | |
} | |
content.each_line{|line| | |
line.chomp! | |
if line == "" | |
next | |
end | |
case on_the_list?(line) | |
when true | |
$stdout.puts "#{RED}#{line}#{NO_COLOUR}" | |
when nil | |
$stdout.puts line | |
when false | |
end | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment