FAQ
Hi,

I have a Catalyst app, running 5.7011, and I keep the debugging log turned
on as the parameters and sequence of events is far more useful than the disk
space and request overhead, at least currently.

Recently, I've had to start accepting credit cards. I'm required to not log
them, but I'd also like to keep the debug log going. So, I've copied
Catalyst.pm's prepare_body() method into MyApp.pm, and added the following
line to the block which prepares the Text::SimpleTable output for the log:

my $t = Text::SimpleTable->new( [ 35, 'Parameter' ], [ 36, 'Value' ]
);
for my $key ( sort keys %{ $c->req->body_parameters } ) {
my $param = $c->req->body_parameters->{$key};
my $value = defined($param) ? $param : '';
+ $value = (grep { $key eq $_ } qw(cardnumber password)) ?
'<masked>' : $value;
$t->row( $key,
ref $value eq 'ARRAY' ? ( join ', ', @$value ) : $value );
}

As you can see, I've taken the opportunity to mask the password from the log
too.

My question is: is there a better, or more Catalyst-approved way of
accomplishing this? This seemed to be the most direct/simple way, but it
would have been nice if the Text::SimpleTable stuff was in a method of its
own.

Thanks,

--
Ewan Edwards, eskwayrd@gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090415/7facd8af/attachment.htm

Search Discussions

  • Tomas Doran at Apr 16, 2009 at 7:56 am
    On 16 Apr 2009, at 00:27, Ewan Edwards wrote:

    <snip>
    As you can see, I've taken the opportunity to mask the password
    from the log too.

    My question is: is there a better, or more Catalyst-approved way of
    accomplishing this? This seemed to be the most direct/simple way,
    but it would have been nice if the Text::SimpleTable stuff was in a
    method of its own.
    This comes up every couple of months, and I for one would like to see
    it happen in a generic way.

    There was a patch for this back in January, which is almost but not
    quite generic enough to apply.

    See this patch:

    http://dev.catalyst.perl.org/svnweb/Catalyst/revision/?rev�38

    and this thread:

    http://lists.scsys.co.uk/pipermail/catalyst/2009-January/020628.html

    If you're interested in helping make this a little more generic (read
    to the end of the thread for more info about what we consider wrong
    with the patch as it stands), then I'm more than happy to branch 5.80
    so we can finish thrashing it out, and get it included in core.

    Cheers
    t0m

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedApr 15, '09 at 11:27p
activeApr 16, '09 at 7:56a
posts2
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Tomas Doran: 1 post Ewan Edwards: 1 post

People

Translate

site design / logo © 2022 Grokbase