Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log error messages via $c->app->pause->log instead of STDERR #522

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/pause_2017/PAUSE/Web/Controller/Public.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ sub mailpw {
# we have.
unless ($email = $rec->{secretemail}) {
my $u = $c->active_user_record($param,{hidden_user_ok => 1});
require YAML::Syck; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . YAML::Syck::Dump({u=>$u}); # XXX

require YAML::Syck;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . YAML::Syck::Dump({u=>$u});
$mgr->log({level => 'debug', message => $message});
$email = $u->{email};
}
if ($email) {
Expand Down
4 changes: 3 additions & 1 deletion lib/pause_2017/PAUSE/Web/Controller/Public/RequestId.pm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ sub request {
userid => $userid,
rationale => $rationale,
};
require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$session->{APPLY}],[qw(APPLY)])->Indent(1)->Useqq(1)->Dump; # XXX
require Data::Dumper;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$session->{APPLY}],[qw(APPLY)])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message });
if (lc($fullname) eq lc($userid)) {
die PAUSE::Web::Exception->new(ERROR => "fullname looks like spam");
}
Expand Down
5 changes: 3 additions & 2 deletions lib/pause_2017/PAUSE/Web/Controller/User/Distperms.pm
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ sub remove_dist_primary {
if (0) {
# here I discovered that Apache::Request has case-insensitive keys
my %p = map { $_, [ $req->every_param($_)] } @{$req->param->names};
require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump; # XXX

require Data::Dumper;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message});
}

if (
Expand Down
5 changes: 3 additions & 2 deletions lib/pause_2017/PAUSE/Web/Controller/User/Perms.pm
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ sub _share_remopr {
if (0) {
# here I discovered that Apache::Request has case-insensitive keys
my %p = map { $_, [ $req->every_param($_)] } @{$req->param->names};
require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump; # XXX

require Data::Dumper;
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([\%p],[qw()])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message});
}

if (
Expand Down
23 changes: 12 additions & 11 deletions lib/pause_2017/PAUSE/Web/Plugin/WrapAction.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ sub _wrap {
}

my $res = eval { $next->(); };
if ($@) {
if (UNIVERSAL::isa($@, "PAUSE::Web::Exception")) {
if ($@->{ERROR}) {
$@->{ERROR} = [ $@->{ERROR} ] unless ref $@->{ERROR} eq 'ARRAY';
push @{$pause->{ERROR}}, @{$@->{ERROR}};
if (my $e = $@) {
if (UNIVERSAL::isa($e, "PAUSE::Web::Exception")) {
if ($e->{ERROR}) {
$e->{ERROR} = [ $e->{ERROR} ] unless ref $e->{ERROR} eq 'ARRAY';
push @{$pause->{ERROR}}, @{$e->{ERROR}};
require Data::Dumper;
print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$pause->{ERROR}],[qw(error)])->Indent(1)->Useqq(1)->Dump; # XXX
$c->res->code($@->{HTTP_STATUS}) if $@->{HTTP_STATUS};
my $message = "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([$pause->{ERROR}],[qw(error)])->Indent(1)->Useqq(1)->Dump;
$c->app->pause->log({level => 'debug', message => $message});
$c->res->code($e->{HTTP_STATUS}) if $e->{HTTP_STATUS};
$c->render('layouts/layout') unless $c->stash('Action');
} elsif ($@->{HTTP_STATUS}) {
} elsif ($e->{HTTP_STATUS}) {
$c->res->headers->content_type('text/plain');
$c->res->body(status_message($@->{HTTP_STATUS}));
$c->rendered($@->{HTTP_STATUS});
$c->res->body(status_message($e->{HTTP_STATUS}));
$c->rendered($e->{HTTP_STATUS});
return;
}
} else {
# this is NOT a known error type, we need to handle it anon
my $error = "$@";
my $error = "$e";
if ($pause->{ERRORS_TO_BROWSER}) {
push @{$pause->{ERROR}}, " ", $error;
} else {
Expand Down