Skip to content
Snippets Groups Projects
Commit 6f374cc5 authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files

- added "--debug" option for user agent debug information

parent 77e57d10
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ Alternatively, copy the 'bin/' and 'lib' paths to your local perl installation. ...@@ -15,6 +15,7 @@ Alternatively, copy the 'bin/' and 'lib' paths to your local perl installation.
OPTIONS: OPTIONS:
-v --verbose Show more detailed option -v --verbose Show more detailed option
-h --help Prints this help information -h --help Prints this help information
--debug Show user agent debug information
COMMAND: COMMAND:
init Initialize config init Initialize config
......
...@@ -22,6 +22,7 @@ SLUB::LZA::Rosetta::TA->run; ...@@ -22,6 +22,7 @@ SLUB::LZA::Rosetta::TA->run;
OPTIONS: OPTIONS:
-v --verbose Show more detailed option -v --verbose Show more detailed option
-h --help Prints this help information -h --help Prints this help information
--debug Show user agent debug information
=head1 DESCRIPTION =head1 DESCRIPTION
......
...@@ -38,6 +38,7 @@ sub description { ...@@ -38,6 +38,7 @@ sub description {
sub opt_spec { sub opt_spec {
return( return(
["verbose|v" => "enable verbose output"], ["verbose|v" => "enable verbose output"],
["debug" => "enable user agent debug output"],
["datemode" => hidden => {one_of => [ ["datemode" => hidden => {one_of => [
["creationdate|c=s" => "search based on creationdate string"], ["creationdate|c=s" => "search based on creationdate string"],
["modificationdate|m=s" => "search based on modificationdate string"] ["modificationdate|m=s" => "search based on modificationdate string"]
...@@ -73,7 +74,7 @@ sub execute { ...@@ -73,7 +74,7 @@ sub execute {
my $maxrecords="0"; my $maxrecords="0";
my $startrecord=1; my $startrecord=1;
my $query = SLUB::LZA::Rosetta::TA::common_sru::prepare_query($opt); my $query = SLUB::LZA::Rosetta::TA::common_sru::prepare_query($opt);
my $response = SLUB::LZA::Rosetta::TA::SRU::sru_search('ie', $query, $startrecord, $maxrecords, $opt->{verbose}); my $response = SLUB::LZA::Rosetta::TA::SRU::sru_search('ie', $query, $startrecord, $maxrecords, $opt->{verbose}, $opt->{debug});
$response=~s|.*?<numberOfRecords>(\d+)</numberOfRecords.*|$1|s; $response=~s|.*?<numberOfRecords>(\d+)</numberOfRecords.*|$1|s;
say $response; say $response;
} }
......
...@@ -43,6 +43,7 @@ sub description { ...@@ -43,6 +43,7 @@ sub description {
sub opt_spec { sub opt_spec {
return( return(
["verbose|v" => "enable verbose output"], ["verbose|v" => "enable verbose output"],
["debug" => "enable user agent debug output"],
["datemode" => hidden => {one_of => [ ["datemode" => hidden => {one_of => [
["creationdate|c=s" => "search based on creationdate string"], ["creationdate|c=s" => "search based on creationdate string"],
["modificationdate|m=s" => "search based on modificationdate string"] ["modificationdate|m=s" => "search based on modificationdate string"]
...@@ -86,7 +87,7 @@ sub execute { ...@@ -86,7 +87,7 @@ sub execute {
$startrecord = $opt->{startrecord}; $startrecord = $opt->{startrecord};
} }
my $query = SLUB::LZA::Rosetta::TA::common_sru::prepare_query($opt); my $query = SLUB::LZA::Rosetta::TA::common_sru::prepare_query($opt);
my $response = SLUB::LZA::Rosetta::TA::SRU::sru_search('ie', $query, $startrecord, $maxrecords, $opt->{verbose}, $opt->{user}, $opt->{password}); my $response = SLUB::LZA::Rosetta::TA::SRU::sru_search('ie', $query, $startrecord, $maxrecords, $opt->{verbose}, $opt->{debug}, $opt->{user}, $opt->{password});
say $response; say $response;
} }
......
...@@ -28,6 +28,7 @@ sub sru_search { ...@@ -28,6 +28,7 @@ sub sru_search {
my $startrecord = shift; my $startrecord = shift;
my $maxrecords = shift; my $maxrecords = shift;
my $is_verbose = shift; my $is_verbose = shift;
my $is_debug = shift;
my %searchpaths = ( my %searchpaths = (
ie => 'permanent/ie', ie => 'permanent/ie',
file => 'permanent/file', file => 'permanent/file',
...@@ -62,7 +63,7 @@ sub sru_search { ...@@ -62,7 +63,7 @@ sub sru_search {
say "searchurl = $sru"; say "searchurl = $sru";
} }
foreach my $retry (1 .. 2) { foreach my $retry (1 .. 2) {
my $console_logger = debug_ua( $ua ); my $console_logger = debug_ua( $ua ) unless (! $is_debug);
my $req = $ua->get($sru); my $req = $ua->get($sru);
if ($req->is_success) { if ($req->is_success) {
my $xres = $req->decoded_content; my $xres = $req->decoded_content;
......
package SLUB::LZA::Rosetta::TA::common_sru; package SLUB::LZA::Rosetta::TA::common_sru;
use strict; use strict;
use warnings; use warnings;
use Data::Printer;
# VERSION # VERSION
...@@ -50,7 +51,6 @@ sub prepare_query { ...@@ -50,7 +51,6 @@ sub prepare_query {
#my $query = join(" and ", @queries); #my $query = join(" and ", @queries);
my $query = join("+", @queries); my $query = join("+", @queries);
if (exists $opt->{debug}) { if (exists $opt->{debug}) {
require Data::Printer;
p( $opt); p( $opt);
p(@queries); p(@queries);
p( $query); p( $query);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment