diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-03-16 20:42:21 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-03-16 20:42:21 +0100 |
commit | 4a1fded77455749b803033eda0fa81a8b429d485 (patch) | |
tree | e62905113aa4d39e015d368be01fb5b79341de3f /lib/Travel/Status | |
parent | 6992ed858018ece96109d9bf07e4ff59e0052337 (diff) |
add optional request logging for delay-stats addon
Diffstat (limited to 'lib/Travel/Status')
-rw-r--r-- | lib/Travel/Status/DE/IRIS.pm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index 2f375eb..9d5eebd 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -11,6 +11,7 @@ our $VERSION = '1.16'; use Carp qw(confess cluck); use DateTime; use DateTime::Format::Strptime; +use File::Slurp qw(write_file); use List::Util qw(first); use List::MoreUtils qw(uniq); use List::UtilsBy qw(uniq_by); @@ -35,6 +36,7 @@ sub new { lookbehind => $opt{lookbehind} // ( 0 * 60 ), main_cache => $opt{main_cache}, rt_cache => $opt{realtime_cache}, + log_dir => $opt{log_dir}, serializable => $opt{serializable}, user_agent => $opt{user_agent}, with_related => $opt{with_related}, @@ -182,6 +184,13 @@ sub get_with_cache { if ($cache) { $cache->freeze( $url, \$content ); } + if ( $self->{log_dir} ) { + my $filename = $url; + $filename =~ s{ ^ .* iris-tts/ }{}x; + $filename =~ tr{/}{_}; + $filename = $self->{datetime}->strftime('%Y%m%d%H%%M%S_') . $filename; + write_file( $self->{log_dir} . '/' . $filename, $content ); + } return ( $content, undef ); } |