sub new {
my $class = shift;
- my $self = {'_DEBUG' => 0,
- '_CONNECTOR' => undef,
+ my $self = {'_CONNECTOR' => undef,
_API => {
- io => sub { printf(@_) },
+ io => sub { print(@_) },
+ io_debug => sub { print(@_) },
connectors => sub { return ({ 'name' => 'direct',
'schemas' => {} }) },
},
my $self = shift;
my @data = @_;
- $data[0] = "DEBUG: " . $data[0];
- if ($self->{'_DEBUG'} != 0) {$self->error(@data)};
+ $data[0] = "(" . ref($self) . ") " . $data[0];
+
+ $self->{_API}->{io_debug}->(@data);
}
sub _getval {
return $s;
}
-sub setdebug {
- my $self = shift;
-
- $self->{'_DEBUG'} = shift;
-}
-
sub ua {
my $self = shift;
my $ua;
my $ua = shift || $self->ua();
my $r;
+ $self->debug("Getting %s", $url);
$r = $ua->get($url);
+ $self->debug("Return code: %s", $r->status_line);
+ $self->debug("Content length: %d", length($r->decoded_content)) if $r->is_success();
return $r->decoded_content() if $r->is_success();
return undef;
}