From e96373c9d64bff7fc0e644ea0927769cbf9885f7 Mon Sep 17 00:00:00 2001 From: hylom Date: Wed, 26 Sep 2018 18:42:34 +0900 Subject: [PATCH] Plugin: remove AccessLog::Debug.pm and AccessLog::LocalFile.pm --- .../lib/Newslash/Plugin/AccessLog/Debug.pm | 26 -------- .../lib/Newslash/Plugin/AccessLog/LocalFile.pm | 77 ---------------------- 2 files changed, 103 deletions(-) delete mode 100644 src/newslash_web/lib/Newslash/Plugin/AccessLog/Debug.pm delete mode 100644 src/newslash_web/lib/Newslash/Plugin/AccessLog/LocalFile.pm diff --git a/src/newslash_web/lib/Newslash/Plugin/AccessLog/Debug.pm b/src/newslash_web/lib/Newslash/Plugin/AccessLog/Debug.pm deleted file mode 100644 index e7da8134..00000000 --- a/src/newslash_web/lib/Newslash/Plugin/AccessLog/Debug.pm +++ /dev/null @@ -1,26 +0,0 @@ -package Newslash::Plugin::AccessLog::Debug; -use Mojo::Base 'Newslash::Plugin::AccessLog'; - -use IO::File; -use File::Basename; - -sub register { - my ($self, $app, $conf) = @_; - $conf ||= {}; - $self->regist_config($app, $conf); - my $cnf = {%$conf, %{$app->config}}; - - return if !$cnf->{debug}; - - - $self->{app} = $app; - $self->add_hook($app); -} - -sub write_log { - my ($self, $log) = @_; - $self->{app}->log->debug($log); -} - - -1; diff --git a/src/newslash_web/lib/Newslash/Plugin/AccessLog/LocalFile.pm b/src/newslash_web/lib/Newslash/Plugin/AccessLog/LocalFile.pm deleted file mode 100644 index f1cb9e28..00000000 --- a/src/newslash_web/lib/Newslash/Plugin/AccessLog/LocalFile.pm +++ /dev/null @@ -1,77 +0,0 @@ -package Newslash::Plugin::AccessLog::LocalFile; -use Mojo::Base 'Newslash::Plugin::AccessLog'; - -use IO::File; -use File::Basename; -use Mojo::Util qw(dumper); - -sub DESTROY { - my $self = shift; - if ($self->{fh}) { - $self->{fh}->flush; - $self->{fh}->close; - } -} - -sub register { - my ($self, $app, $conf) = @_; - $conf ||= {}; - $self->regist_config($app, $conf); - - my $cnf = {%$conf, %{$app->config->{Log}->{access_log}}}; - $self->{app} = $app; - $self->{config} = $cnf; - - # local file output - if ($cnf->{local_file}) { - my $log_dest = $cnf->{local_file}; - $self->{fh} = $self->_open_or_create_file($log_dest); - if (!$self->{fh}) { - $app->log->error("cannot open access log file: $log_dest"); - } - if (!defined $cnf->{autoflush} || $cnf->{autoflush}) { - $self->{fh}->autoflush; - } - } - - # mojolicios embedded log output - if ($cnf->{mojo_log}) { - } - - $self->add_hook($app); -} - -sub write_log { - my ($self, $log) = @_; - print {$self->{fh}} "$log\n"; -} - -sub _open_or_create_file { - my ($self, $pathname) = @_; - - if (-w $pathname) { - return IO::File->new($pathname, "a"); - } - - if (-e $pathname) { - $self->{app}->log->error("AccessLog::LocalFile: $pathname exists, but not writable"); - return; - } - - my $parent = dirname($pathname); - if (! -d $parent) { - $self->{app}->log->error("AccessLog::LocalFile: cannot create $pathname: $parent not exists"); - return; - } - - my $fh = IO::File->new($pathname, "a"); - if (!$fh) { - $self->{app}->log->error("AccessLog::LocalFile: cannot create $pathname"); - return; - } - - return $fh; -} - - -1; -- 2.11.0