transform_exceptions
);
-use System::Introspector::Logger qw ( :log );
+use System::Introspector::Logger qw ( :log :dlog );
with 'System::Introspector::Role::Probe';
return transform_exceptions {
log_trace { "Invoking lsof" };
my @lines = lines_from_command [$self->_lsof_command_call];
- log_trace { "lsof has finished executing" };
+ log_trace { "lsof has finished executing" } ;
my @handles;
for my $line (@lines) {
chomp $line;
($1, $2);
} @fields };
}
- log_trace { "Completed gathering open file information" };
+ Dlog_trace { "Completed gathering open file information: $_" } @handles;
return { handles => \@handles };
};
}
sub gather {
my ($self) = @_;
- log_debug { "Starting to gather host information" };
+ log_debug { "Gathering host information" };
return transform_exceptions {
return {
hostname => $self->_gather_hostname,
sub _gather_uname_info {
my ($self) = @_;
my %uname;
+ log_trace { "Gathering uname info" };
for my $field (@UnameFields) {
(my $option = $field) =~ s{_}{-}g;
- log_trace { "Invoking uname with option of '--$option'" };
my $value = output_from_command [uname => "--$option"];
chomp $value;
$uname{ $field } = $value;
use File::Spec;
use Scalar::Util qw( blessed );
use Capture::Tiny qw( capture_stderr );
+use System::Introspector::Logger qw( :log :dlog );
+
our @EXPORT_OK = qw(
handle_from_command
sub files_from_dir {
my ($dir) = @_;
my $dh;
+ log_trace { "Enumerating files in '$dir'" };
opendir $dh, $dir
or fail "Unable to read directory $dir: $!";
my @files;
next if -d "$dir/$item";
push @files, $item;
}
- return @files;
+ return Dlog_trace { "File list for '$dir': $_" } @files;
}
sub transform_exceptions (&) {
$in = ''
unless defined $in;
my ($out, $err) = ('', '');
+ Dlog_trace { "executing command with IPC::Run: $_" } @$command;
my $ok = eval { run($command, \$in, \$out, \$err) or die $err};
+ log_trace { $ok ? "command executed successfully" : "command did not execute successfully" };
$err = $@ unless $ok;
return $out, $err, $ok
if wantarray;
my ($command) = @_;
my $pipe;
local $@;
+ log_trace { "Converting output of '$command' into a readable pipe" };
my $ok = eval {
my $out;
my $child_pid;
open $pipe, '<', \$content;
1;
};
+ log_trace { "Completed reading output of '$command'" };
unless ($ok) {
my $err = $@;
die $err
sub handle_from_file {
my ($file) = @_;
+ log_trace { "Creating filehandle for file '$file'" };
open my $fh, '<', $file
or fail "Unable to read $file: $!";
+ log_trace { "Finished opening '$file'" };
return $fh;
}