package CPAN::InstallLog;

use strict;
use warnings;
use CPAN;

my $orig = CPAN::Distribution->can('install');

open INSTALLLOG, '>>', 'install.log';

my $replace = 
 sub {
    my $res = $orig->(@_);
    if (defined($res) && $res eq 'YES') {
      print INSTALLLOG $_[0]->normalize."\n";
    }
    return $res;
  };

{
  no warnings 'redefine';
  *CPAN::Distribution::install = \&$replace;
}

1;
