diff --git a/lib/App/Frame.pm b/lib/App/Frame.pm index 6616ff23e45099d21e736635af3a31e5517dc9f2..cd29ea86cdc07f1a7367b0e5d5259d17b46607f8 100644 --- a/lib/App/Frame.pm +++ b/lib/App/Frame.pm @@ -3,6 +3,13 @@ package Frame; use strict; use warnings; +BEGIN +{ + unshift @INC, '.'; +} + +use App::Log; + use Data::Dumper; sub debug_frame @@ -14,11 +21,11 @@ sub debug_frame sub frame_info { my $frame = $_[0]; - print "Frame for line $frame->{'rosenmei'}:\n"; - print ". $frame->{'eki_num'} stations\n"; - print ". " . scalar @{ $frame->{'syubetsu'} } . " service types\n"; - print ". " . scalar @{ $frame->{'dia'}->{'kudari'} } . " down services\n"; - print ". " . scalar @{ $frame->{'dia'}->{'nobori'} } . " up services\n"; + Log::d "Frame for line $frame->{'rosenmei'}:\n"; + Log::d ". $frame->{'eki_num'} stations\n"; + Log::d ". " . scalar @{ $frame->{'syubetsu'} } . " service types\n"; + Log::d ". " . scalar @{ $frame->{'dia'}->{'kudari'} } . " down services\n"; + Log::d ". " . scalar @{ $frame->{'dia'}->{'nobori'} } . " up services\n"; } 1; diff --git a/lib/App/Navi.pm b/lib/App/Navi.pm index fb3a56ee171053dea9aa6c4594cce94d41f5afe6..f0e57b25b52e9eb5aae3e3a5677d851e337c8b55 100644 --- a/lib/App/Navi.pm +++ b/lib/App/Navi.pm @@ -30,7 +30,7 @@ sub Raptor_simple my $from = MasterUtils::sta_from_id $master, $from_id; my $to = MasterUtils::sta_from_id $master, $to_id; - print "Calculating fastest routes from $from->{'ekimei'} to $to->{'ekimei'} leaving at $dep_time with $MAX_LEGS maximum legs\n"; + Log::i "Calculating fastest routes from $from->{'ekimei'} to $to->{'ekimei'} leaving at $dep_time with $MAX_LEGS maximum legs\n"; # From now on we are just blindly following the algorithm from the paper... # Use ~0 as a substitute to infty, not that travel times would exceed this anyway diff --git a/src/oud2_parser.pl b/src/oud2_parser.pl index 6a62c0447379ad93b12947dab5caeea5b73731dc..b2d7aeb0277c2d55fc99959f013d1e88e086087d 100644 --- a/src/oud2_parser.pl +++ b/src/oud2_parser.pl @@ -281,18 +281,17 @@ foreach my $file (@trains) my $recce = new_recce (); my $train_path = $trains_path . $file; - print 'Using file ' . $train_path . "\n"; + Log::d 'Using file ' . $train_path . "\n"; open $dia_file, '<:encoding(UTF-8):via(File::BOM)', $train_path; my $file_name = basename $file; my $basename = substr $file_name, 0, -5; - print "Route id will be $basename\n"; + Log::d "Route id will be $basename\n"; read $dia_file, my $contents, -s $dia_file; - try { print $recce->read(\$contents) . ' bytes read.'; } - catch ($e) { print "Malformation in .oud file.\n$e\n"; } - print "\n"; + try { Log::d ($recce->read(\$contents) . ' bytes read.'); } + catch ($e) { Log::w "Malformation in .oud file.\n$e\n"; } # print $recce->show_progress(); @@ -317,18 +316,17 @@ foreach my $file (@bus) my $recce = new_recce (); my $abus_path = $bus_path . $file; - print 'Using file ' . $abus_path . "\n"; + Log::d 'Using file ' . $abus_path . "\n"; open $dia_file, '<:encoding(UTF-8):via(File::BOM)', $abus_path; my $file_name = basename $file; my $basename = substr $file_name, 0, -5; - print "Route id will be $basename\n"; + Log::d "Route id will be $basename\n"; read $dia_file, my $contents, -s $dia_file; - try { print $recce->read(\$contents) . ' bytes read.'; } - catch ($e) { print "Malformation in .oud file.\n$e\n"; } - print "\n"; + try { Log::d ($recce->read(\$contents) . ' bytes read.'); } + catch ($e) { Log::w "Malformation in .oud file.\n$e\n"; } # print $recce->show_progress(); @@ -402,7 +400,7 @@ foreach my $frame (values %{ $master{'rosen'} }) if ($restart) { next; } my $id = $frame->{'id'} . "_$index"; - print "Adding station $ekimei to master frame with id $id\n"; + Log::d "Adding station $ekimei to master frame with id $id\n"; $new_struct{'ekimei'} = $ekimei; $new_struct{'found_in'} = $frame->{'id'}; $new_struct{'found_as_train_stop'} = $is_train; @@ -427,11 +425,11 @@ my $recce = Marpa::R2::Scanless::R->new( ); open my $tt_file, '<:encoding(UTF-8):via(File::BOM)', $tt_path; -print "Parsing transfer times\n"; +Log::d "Parsing transfer times\n"; read $tt_file, my $tt_contents, -s $tt_file; -try { print $recce->read(\$tt_contents) . ' bytes read.'; } -catch ($e) { print "Malformation in transfer_times file.\n$e\n"; } +try { Log::d ($recce->read(\$tt_contents) . ' bytes read.'); } +catch ($e) { Log::w "Malformation in transfer_times file.\n$e\n"; } print "\n"; my $transfers = ${ $recce->value() }; @@ -439,7 +437,7 @@ foreach my $transfer (@$transfers) { my $where = $transfer->{'where'}; my $time = $transfer->{'time'}; - print "Transfer time is $time' between $where->[0] and $where->[1]\n"; + Log::d "Transfer time is $time' between $where->[0] and $where->[1]\n"; $transfer->{'where'} = [ (MasterUtils::search_eki \%master, $where->[0]),