Module: ReactNativeLogCat
- Defined in:
- lib/react-native-logcat.rb,
lib/react-native-logcat/version.rb
Constant Summary collapse
- VERSION =
"0.2.4"
Class Method Summary collapse
Class Method Details
.add_timestamp(str) ⇒ Object
6 7 8 9 |
# File 'lib/react-native-logcat.rb', line 6 def self.(str) = Time.now.strftime("%H:%M:%S") return "[#{}] #{str}" end |
.clean(str) ⇒ Object
11 12 13 |
# File 'lib/react-native-logcat.rb', line 11 def self.clean(str) return str[/^[A-Z]\/.*\):(.*)/,1] end |
.start ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/react-native-logcat.rb', line 36 def self.start cmd=' adb logcat *:S ReactNative:V ReactNativeJS:V | { while IFS= read -r line do echo "$line" done }' IO.popen(cmd).each do |line| puts self.transform_line(line.chomp) end end |
.transform_line(str) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/react-native-logcat.rb', line 15 def self.transform_line(str) if str[0..1] == "D/" return (clean(str).green) end if str[0..1] == "W/" return (clean(str).yellow) end if str[0..1] == "E/" return (clean(str).red) end if str[0..1] == "I/" return (clean(str).white) end return (str) end |