Permalink
Browse files

--map feature

  • Loading branch information...
1 parent 52f7f27 commit ba34206a727ac23d67b79685c5600cace810cc09 @hoytech committed Aug 23, 2013
Showing with 11 additions and 0 deletions.
  1. +11 −0 bin/log-defer-viz
View
@@ -60,6 +60,7 @@ my @opt_spec = (
'help|h|?',
'grep|g=s',
+ 'map|m=s',
);
my $opt = {
@@ -125,6 +126,9 @@ if ($opt->{grep}) {
$opt->{grep} = eval('sub { local $_ = $_[0]; ' . $opt->{grep} . '}');
}
+if ($opt->{map}) {
+ $opt->{map} = eval('sub { local $_ = $_[0]; ' . $opt->{map} . '}');
+}
unshift(@ARGV, '-') unless @ARGV;
@@ -164,6 +168,13 @@ sub handle_entry {
return if $opt->{grep} && !$opt->{grep}->($entry);
+ if ($opt->{map}) {
+ my $output = $opt->{map}->($entry);
+ $output = "$output\n" unless $output =~ /\n$/;;
+ print $output;
+ return;
+ }
+
my $millis = '';
if ($entry->{start} =~ /[.](\d+)$/) {

0 comments on commit ba34206

Please sign in to comment.