Permalink
Browse files

Remove Logging::Trivial; insert Log4Perl

  • Loading branch information...
alexander-brett committed May 3, 2015
1 parent 4c7d630 commit 232c807bbe285525f064e1fcd510a1058bf0659d
@@ -16,7 +16,6 @@ WriteMakefile(
},
BUILD_REQUIRES => {
'File::Slurp' => 0,
'Logging::Trivial' => 0,
'Test::Exception' => 0,
'Config::Properties' => 0,
'Test::More' => 0,
@@ -25,7 +24,7 @@ WriteMakefile(
'IO::Compress::Zip' => 0,
'IO::Uncompress::Unzip' => 0,
'List::NSect' => 0,
'Logging::Trivial' => 0,
'Log::Log4Perl' => 0,
'Moo' => 0,
'Moo::Role' => 0,
'MooX::Singleton' => 0,
@@ -6,7 +6,7 @@ use 5.12.0;
use strict;
use warnings;
use Logging::Trivial;
use Log::Log4perl ':easy';
use WWW::SFDC::SessionManager;
use Moo;
@@ -61,11 +61,12 @@ sub executeAnonymous {
))->uri($self->uri) : (),
);
ERROR "ExecuteAnonymous failed to compile: " . $result->{compileProblem}
LOGDIE "ExecuteAnonymous failed to compile: " . $result->{compileProblem}
if $result->{compiled} eq "false";
ERROR "ExecuteAnonymous failed to complete: " . $result->{exceptionMessage}
if $result->{success} eq "false";
LOGDIE "ExecuteAnonymous failed to complete: " . $result->{exceptionMessage}
if ($result->{success} eq "false");
return $result, (defined $headers ? $headers->{debugLog} : ());
}
@@ -3,6 +3,7 @@ package WWW::SFDC::Constants;
use 5.12.0;
use strict;
use warnings;
use Log::Log4Perl ':easy';
use List::Util 'first';
@@ -279,7 +280,7 @@ sub getDiskName {
sub getName {
my $type = shift;
return $TYPES{$type}->{name} or die "Type $type doesn't have a name!";
return $TYPES{$type}->{name} or LOGDIE "Type $type doesn't have a name!";
}
=head2 getSubcomponents
@@ -8,7 +8,7 @@ use XML::Parser;
use Scalar::Util qw(blessed);
use List::Util qw'first reduce pairmap pairgrep pairfirst';
use Data::Dumper;
use Logging::Trivial;
use Log::Log4Perl ':easy';
use WWW::SFDC::Constants qw(needsMetaFile hasFolders getEnding getDiskName getName);
use Moo;
@@ -56,15 +56,15 @@ and get a structure suitable for passing into WWW::SFDC::Metadata functions.
sub _splitLine {
my ($self, $line) = @_;
ERROR "No line!" unless $line;
LOGDIE "No line!" unless $line;
# clean up the line
$line =~ s/.*src\///;
$line =~ s/[\n\r]//g;
my %result = ("extension" => "");
($result{"type"}) = $line =~ /^(\w+)\// or ERROR "Line $line doesn't have a type.";
($result{"type"}) = $line =~ /^(\w+)\// or LOGDIE "Line $line doesn't have a type.";
$result{"folder"} = $1 if $line =~ /\/(\w+)\//;
my $extension = getEnding($result{"type"});
@@ -80,7 +80,7 @@ sub _splitLine {
$result{"extension"} = $2;
}
ERROR "Line $line doesn't have a name." unless $result{"name"};
LOGDIE "Line $line doesn't have a name." unless $result{"name"};
return \%result;
}
@@ -191,7 +191,7 @@ sub addList {
my $self = shift;
return reduce {$a->add($b)} $self, map {
DEBUG "adding..." => $_;
DEBUG "Adding $_ to manifest";
+{ getName($$_{type}) => [
defined $$_{folder}
? (($self->isDeletion ? () : $$_{folder}), "$$_{folder}/$$_{name}")
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Data::Dumper;
use Logging::Trivial;
use Log::Log4Perl ':easy';
use WWW::SFDC::SessionManager;
use Moo;
@@ -108,7 +108,7 @@ same data as checkRetrieval. Requires a manifest of the form:
# returns just the id, for checking later. Accepts a manifest.
sub _startRetrieval {
INFO "Starting retrieval\n";
INFO "Starting retrieval";
my ($self, $manifest) = @_;
@@ -142,7 +142,7 @@ sub _startRetrieval {
sub _checkRetrieval {
my ($self, $id) = @_;
ERROR "No ID was passed in!" unless $id;
LOGDIE "No ID was passed in!" unless $id;
my $result = $self->_call(
'checkRetrieveStatus',
@@ -153,14 +153,14 @@ sub _checkRetrieval {
return $result->{zipFile} if $$result{status} eq "Succeeded";
return undef if $$result{status} =~ /Pending|InProgress/;
ERROR "Check Retrieve had an unexpected result: ".$$result{message};
LOGDIE "Check Retrieve had an unexpected result: ".$$result{message};
}
sub retrieveMetadata {
my ($self, $manifest) = @_;
ERROR "This method must be called with a manifest" unless $manifest;
LOGDIE "This method must be called with a manifest" unless $manifest;
my $requestId = $self->_startRetrieval($manifest);
@@ -184,7 +184,7 @@ guide for a description.
#Check up on an async deployment request. Returns 1 when complete.
sub _checkDeployment {
my ($self, $id) = @_;
ERROR "No ID was passed in" unless $id;
LOGDIE "No ID was passed in" unless $id;
my ($result) = $self->_call(
'checkDeployStatus',
@@ -196,9 +196,9 @@ sub _checkDeployment {
return 1 if $$result{status} eq "Succeeded";
return undef if $$result{status} =~ /Queued|Pending|InProgress/;
# useful deployment error here please
ERROR "DEPLOYMENT FAILED: ".Dumper $result->{details}->{componentFailures}
LOGDIE "DEPLOYMENT FAILED: ".Dumper $result->{details}->{componentFailures}
if $result->{status} eq "Failed";
ERROR "Check Deploy had an unexpected result: ".Dumper $result;
LOGDIE "Check Deploy had an unexpected result: ".Dumper $result;
}
sub deployMetadata {
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Data::Dumper;
use Logging::Trivial;
use Log::Log4Perl ':easy';
use Scalar::Util 'blessed';
use WWW::SFDC::SessionManager;
@@ -52,7 +52,7 @@ sub _prepareSObjects {
# prepares an array of objects for an update or insert call by converting
# it to an array of SOAP::Data
DETAIL "objects for operation" => \@_;
TRACE "objects for operation", Dumper \@_;
return map {
my $obj = $_;
@@ -81,7 +81,7 @@ sub _prepareSObjects {
sub setPassword {
my ($self, %params) = @_;
ERROR "You must provide an Id and Password" unless $params{Id} and $params{Password};
LOGDIE "You must provide an Id and Password" unless $params{Id} and $params{Password};
INFO "Setting password for user $params{Id}";
return $self->_call(
'setPassword',
@@ -5,7 +5,7 @@ use strict;
use warnings;
use List::NSect 'spart';
use Logging::Trivial;
use Log::Log4Perl ':easy';
use Moo::Role;
use Scalar::Util 'blessed';
use SOAP::Lite;
@@ -148,7 +148,7 @@ Returns an array that looks like [{success => 1, id => 'id'}, {}...] with LOWERC
sub update {
my $self = shift;
DETAIL "Objects for update" => \@_;
TRACE "Objects for update" => \@_;
INFO "Updating objects";
return $self->_call(
@@ -4,7 +4,8 @@ use 5.12.0;
use strict;
use warnings;
use Logging::Trivial;
use Data::Dumper;
use Log::Log4Perl ':easy';
use Moo;
with 'MooX::Singleton';
@@ -51,7 +52,7 @@ has 'url',
has 'apiVersion',
is => 'ro',
isa => sub { ERROR "The API version must be >= 31" unless $_[0] and $_[0] >= 31},
isa => sub { LOGDIE "The API version must be >= 31" unless $_[0] and $_[0] >= 31},
default => '33.0';
has 'loginResult',
@@ -75,8 +76,8 @@ sub _login {
SOAP::Data->name("password")->value($self->password())
);
DETAIL "request" => $request;
ERROR "Login Failed: ".$request->faultstring if $request->fault;
TRACE "request " => Dumper $request;
LOGDIE "Login Failed: ".$request->faultstring if $request->fault;
return $request->result();
}
@@ -111,8 +112,8 @@ sub call {
$req = $self->_doCall(@_);
}
DETAIL "Operation request" => $req;
ERROR "$_[0] Failed: " . $req->faultstring if $req->fault;
TRACE "Operation request " => Dumper $req;
LOGDIE "$_[0] Failed: " . $req->faultstring if $req->fault;
return $req;
};
@@ -4,7 +4,7 @@ use 5.12.0;
use strict;
use warnings;
use Logging::Trivial;
use Log::Log4Perl ':easy';
use WWW::SFDC::SessionManager;
use Scalar::Util 'blessed';
@@ -57,7 +57,7 @@ sub _prepareSObjects {
# THIS IMPLEMENTATION IS DIFFERENT TO THE EQUIVALENT PARTNER API IMPLEMENTATION
DETAIL "objects for operation" => \@_;
TRACE "objects for operation" => \@_;
return map {
my $obj = $_;
@@ -109,10 +109,10 @@ sub executeAnonymous {
)) : (),
);
ERROR "ExecuteAnonymous failed to compile: " . $result->{compileProblem}
LOGDIE "ExecuteAnonymous failed to compile: " . $result->{compileProblem}
if $result->{compiled} eq "false";
ERROR "ExecuteAnonymous failed to complete: " . $result->{exceptionMessage}
LOGDIE "ExecuteAnonymous failed to complete: " . $result->{exceptionMessage}
if $result->{success} eq "false";
return $result;
@@ -11,7 +11,7 @@ use IO::Uncompress::Unzip qw($UnzipError);
use File::Path qw(mkpath);
use IO::Compress::Zip qw{$ZipError zip :constants};
use Logging::Trivial;
use Log::Log4Perl ':easy';
=head1 NAME
@@ -70,11 +70,11 @@ sub unzip {
my ($dest, $data, $callback) = @_;
INFO "Unzipping files to $dest";
DEBUG "Data to unzip" => $data;
ERROR "No destination!" unless $dest;
LOGDIE "No destination!" unless $dest;
$data = decode_base64 $data;
my $unzipper = IO::Uncompress::Unzip->new(\$data)
or ERROR "Couldn't unzip data";
or LOGDIE "Couldn't unzip data";
my $status;
@@ -84,7 +84,7 @@ sub unzip {
$folder =~ s/unpackaged/$dest/;
# create folder on disk unless it exists already
mkpath($folder) or ERROR "Couldn't mkdir $folder: $!" unless -d $folder;
mkpath($folder) or LOGDIE "Couldn't mkdir $folder: $!" unless -d $folder;
# skip if the file is a folder, exit on error
$status < 0 ? last : next if $name =~ /\/$/;
@@ -100,13 +100,13 @@ sub unzip {
if ($content) {
# open target for writing
my $fh = IO::File->new($path, "w") or ERROR "Couldn't write to $path: $!";
my $fh = IO::File->new($path, "w") or LOGDIE "Couldn't write to $path: $!";
$fh->binmode();
$fh->write($content);
$fh->close();
# update time on target
my $stored_time = $header->{'Time'};
utime ($stored_time, $stored_time, $path) or ERROR "Couldn't touch $path: $!";
utime ($stored_time, $stored_time, $path) or LOGDIE "Couldn't touch $path: $!";
}
} until ($status = $unzipper->nextStream()) < 1;
@@ -124,7 +124,7 @@ sub makezip {
my ($baseDir, @files) = @_;
INFO "Writing zip file with ". scalar(@files) ." files";
DEBUG "File list before grep" => \@files;
ERROR "No files!" unless scalar @files;
LOGDIE "No files!" unless scalar @files;
@files = grep {-e $_ && !-d $_}
map {$baseDir.$_}
@@ -140,7 +140,7 @@ sub makezip {
Level => 9,
Minimal => 1,
BinModeIn => 1,
or ERROR "zip failed: $ZipError";
or LOGDIE "zip failed: $ZipError";
eval {
open my $FH, '>', 'data_perl.zip' or die;

0 comments on commit 232c807

Please sign in to comment.