App-logcat_format
view release on metacpan or search on metacpan
lib/App/logcat_format.pm view on Meta::CPAN
package App::logcat_format;
# ABSTRACT: pretty print adb logcat output
use strict;
use warnings;
use Cache::LRU;
use Term::ReadKey;
use Term::ANSIColor;
use IO::Async::Loop;
use IO::Async::Process;
use Getopt::Long::Descriptive;
use IO::Interactive qw( is_interactive );
=pod
=head1 NAME
logcat_format - pretty print android adb logcat output
=head1 DESCRIPTION
A tool to pretty print the output of the android sdk 'adb logcat' command.
=head1 SYNOPSIS
Default adb logcat pretty print ..
% logcat_format
For default logcat output for emulator only ..
% logcat_format -e
For default logcat output for device only ..
% logcat_format -d
For other adb logcat commands, just pipe into logcat_format ..
% adb logcat -v threadtime | logcat_format
% adb -e logcat -v process | logcat_format
=head1 VERSION
version 0.06
=cut
# set it up
my ($opt, $usage) = describe_options(
'logcat_format',
[ 'emulator|e', "connect to emulator", ],
[ 'device|d', "connect to device", ],
[],
[ 'help|h', "print usage message and exit" ],
);
print($usage->text), exit if $opt->help;
my %priority =
(
V => 'bold black on_bright_white', # Verbose
D => 'bold black on_bright_blue', # Debug
I => 'bold black on_bright_green', # Info
W => 'bold black on_bright_yellow', # Warn
E => 'bold black on_bright_red', # Error
F => 'bold white on_black', # Fatal
S => 'not printed', # Silent
);
my %known_tags =
(
dalvikvm => 'bright_blue',
PackageManager => 'cyan',
ActivityManager => 'blue',
);
my $cache = Cache::LRU->new( size => 1000 );
my @colors = ( 1 .. 15 );
my ( $wchar, $hchar, $wpixels, $hpixels ) = GetTerminalSize();
my %longline;
sub run
{
my $class = shift;
if ( is_interactive() )
{
# kick off adb logcat with args
my $loop = IO::Async::Loop->new;
my $argument = '-a';
$argument = '-e' if $opt->emulator;
$argument = '-d' if $opt->device;
my $process = IO::Async::Process->new(
command => [ 'adb', $argument, 'logcat' ],
stdout => {
( run in 1.765 second using v1.01-cache-2.11-cpan-140bd7fdf52 )