Skip to content

Commit

Permalink
Adding stubs for debugging calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
msjohns1 committed Nov 4, 2017
1 parent 31fa9f2 commit 6dc4dc1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Vend/Payment/GatewayLog.pm
Expand Up @@ -7,6 +7,7 @@ use Time::HiRes;

sub new {
my ($class, $self) = @_;
#::logDebug("Called in class $class, with initial hash %s", ::uneval($self));
$self = {} unless ref ($self) eq 'HASH';
$self->{_log_table} = $self->{LogTable} || 'gateway_log';
$self->{_enabled} = $self->{Enabled} || '';
Expand All @@ -20,6 +21,7 @@ sub start {
my $override = shift;
$self->{__start} = Time::HiRes::clock_gettime()
if $override || !$self->{__start};
#::logDebug("Start time: $self->{__start}");
return $self->{__start};
}

Expand All @@ -29,21 +31,26 @@ sub stop {
my $override = shift;
$self->{__stop} = Time::HiRes::clock_gettime()
if $override || !$self->{__stop};
#::logDebug("Stop time: $self->{__stop}");
return $self->{__stop};
}

sub duration {
my $self = shift;
return unless $self->_enabled;
my $fmt = shift || '%0.3f';
return sprintf ($fmt, $self->stop - $self->start);
my $rv = sprintf ($fmt, $self->stop - $self->start);
#::logDebug("Duration calculated at $rv");
return $rv;
}

sub timestamp {
my $self = shift;
return unless $self->_enabled;
my $fmt = shift || '%Y-%m-%d %T';
return POSIX::strftime($fmt, localtime($self->start));
my $rv = POSIX::strftime($fmt, localtime($self->start));
#::logDebug("Start formatted timestamp returned $rv");
return $rv;
}

sub request {
Expand All @@ -60,6 +67,7 @@ sub request {
);
return;
}
#::logDebug('Setting request: %s', ::uneval($request));
$self->{__request} = { %$request };
}

Expand All @@ -77,6 +85,7 @@ sub response {
);
return;
}
#::logDebug('Setting response: %s', ::uneval($response));
$self->{__response} = { %$response };
}

Expand All @@ -85,6 +94,7 @@ sub clean {
return unless $self->_enabled;
delete $self->{$_}
for grep { /^__/ } keys %$self;
#::logDebug('Cleaned all object data');
return 1;
}

Expand Down Expand Up @@ -120,6 +130,7 @@ sub write {
);
}
else {
#::logDebug('Cleaning out object data after successful write to database');
$self->clean;
}

Expand All @@ -137,6 +148,7 @@ sub _enabled {
sub DESTROY {
my $self = shift;
return 1 unless $self->_enabled;
#::logDebug('Logging request to database in destructor');
$self->log_it;
1;
}
Expand Down

0 comments on commit 6dc4dc1

Please sign in to comment.