Skip Menu |

This queue is for tickets about the Apache2-AuthCookieDBI CPAN distribution.

Report information
The Basics
Id: 75675
Status: resolved
Worked: 1.2 hours (70 min)
Priority: 0/
Queue: Apache2-AuthCookieDBI

People
Owner: Nobody in particular
Requestors: ccolumbu [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 2.15



Subject: Feature request for mysql logging
Matisse, I had to hack in the mysql logging code again for a new client, and thought I would submit it to you again in case you want to include it in the module. I have attached my copy of the module with the code changes. I assume it will need testing in your usual way.
Subject: AuthCookieDBI.pm

Message body is not shown because it is too large.

Chad, how about you create a sub-class of the module that implements the SQL logging you want? If you do this I will modify AuthCookieDBI.pm to call a logging method in many places throughout the code, starting with the places where you added calls to log_to_sql() We'd need to agree on a generalized API for what arguments the logging method would get called with - this will allow users of AuthCookieDBI.pm to implement their own logging approach and not be tied to the one you chose. So, for example, in your modified version of the module right now in the group() method there is: $r->log_error( "$class: user $user was not a member of any of the required groups @groups for auth realm $auth_name", $r->uri ); &log_to_sql($class, $r, "$class: user $user was not a member of any of the required groups @groups for auth realm $auth_name", $user); I would replace both of those lines with something like this: my $message = "$class: user $user was not a member of any of the required groups @groups for auth realm $auth_name"; $class->logger($r, 'error' , $message, $user, @groups); and I will add a new logger() method to AuthCookieDBI.pm which would look something like this: sub logger { my ($class,$r, $log_level, $message, $user, @extra_args) = @_; # $log_level should be one of: emerg alert crit error warn notice info debug $r->log->$log_level($message, @extra_args); } In your sub-class of AuthCookieDBI.pm you would override the logger() method with something like this: sub logger { my ($class,$r, $log_level, $display_message, $user, @extra_args) = @_; # $log_level should be one of: emerg alert crit error warn notice info debug $r->log->$log_level($message, @extra_args); $class->log_to_sql( $r, $display_message, $user); }
From: ccolumbu [...] gmail.com
On Sun Mar 11 14:33:03 2012, MATISSE wrote: Show quoted text
> Chad, > > how about you create a sub-class of the module that implements the SQL > logging you want? > If you do this I will modify AuthCookieDBI.pm to call a logging method > in many places > throughout the code, starting with the places where you added calls to > log_to_sql() > > We'd need to agree on a generalized API for what arguments the logging > method would get > called with - this will allow users of AuthCookieDBI.pm to implement > their own logging approach > and not be tied to the one you chose. > > > So, for example, in your modified version of the module right now in > the group() method there > is: > > > > $r->log_error( > "$class: user $user was not a member of any of the required > groups @groups for auth > realm $auth_name", > $r->uri > ); > &log_to_sql($class, $r, "$class: user $user was not a member of > any of the required groups > @groups for auth realm $auth_name", $user); > > > I would replace both of those lines with something like this: > > my $message = "$class: user $user was not a member of any of the > required groups @groups > for auth realm $auth_name"; > $class->logger($r, 'error' , $message, $user, @groups); > > and I will add a new logger() method to AuthCookieDBI.pm which would > look something like this: > > sub logger { > my ($class,$r, $log_level, $message, $user, @extra_args) = @_; > # $log_level should be one of: emerg alert crit error warn notice > info debug > $r->log->$log_level($message, @extra_args); > } > > In your sub-class of AuthCookieDBI.pm you would override the logger() > method with something > like this: > > sub logger { > my ($class,$r, $log_level, $display_message, $user, @extra_args) = > @_; > # $log_level should be one of: emerg alert crit error warn notice > info debug > $r->log->$log_level($message, @extra_args); > $class->log_to_sql( $r, $display_message, $user); > }
I can subclass this module, I have never done that before (or published on CPAN), but I read about it and it does not seem to hard. I did find one more place where I would want to send errors to the sql log, which is in the _get_crypted_password sub inside this error check: if ( !$class->user_is_active( $r, $user ) ) { I am wondering if we should just pass all errors to this new logging method and add a "type" of error, so I can just control "login" type errors (which is all I care about), but others could overwrite or log to sql other types. Adding a "session" type error for things missing DBI_SecretKey and such. I am not sure how granular you would want to make this though.
On Sun Mar 11 14:58:40 2012, ccolumbu wrote: Show quoted text
> I can subclass this module, I have never done that before (or published > on CPAN), but I read about it and it does not seem to hard. > > I did find one more place where I would want to send errors to the sql > log, which is in the _get_crypted_password sub inside this error check: > if ( !$class->user_is_active( $r, $user ) ) { > > I am wondering if we should just pass all errors to this new logging > method and add a "type" of error, so I can just control "login" type > errors (which is all I care about), but others could overwrite or log to > sql other types. Adding a "session" type error for things missing > DBI_SecretKey and such. I am not sure how granular you would want to > make this though.
Yes I would replace ALL logging calls with calls to the logger method, as well as adding some new ones. Adding a 'type' argument is a reasonable idea. Here's what I suggest: You implement a sub-class and the changes in the base-class that support what you need, and attach the proposed new base class to this ticket. I'll review it, add tests where needed, etc. Once we agree on the API I'll make release a new official version of AuthCookieDBI with the changes.
Subject: Re: [rt.cpan.org #75675] Feature request for mysql logging
Date: Sun, 11 Mar 2012 14:49:21 -0700
To: bug-Apache2-AuthCookieDBI [...] rt.cpan.org
From: Chad <ccolumbu [...] gmail.com>
On 3/11/2012 1:43 PM, Matisse Enzer via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=75675> > > On Sun Mar 11 14:58:40 2012, ccolumbu wrote:
>> I can subclass this module, I have never done that before (or published >> on CPAN), but I read about it and it does not seem to hard. >> >> I did find one more place where I would want to send errors to the sql >> log, which is in the _get_crypted_password sub inside this error check: >> if ( !$class->user_is_active( $r, $user ) ) { >> >> I am wondering if we should just pass all errors to this new logging >> method and add a "type" of error, so I can just control "login" type >> errors (which is all I care about), but others could overwrite or log to >> sql other types. Adding a "session" type error for things missing >> DBI_SecretKey and such. I am not sure how granular you would want to >> make this though.
> > Yes I would replace ALL logging calls with calls to the logger method, as well as adding some > new ones. > > Adding a 'type' argument is a reasonable idea. > > Here's what I suggest: You implement a sub-class and the changes in the base-class that > support what you need, and attach the proposed new base class to this ticket. I'll review it, add > tests where needed, etc. Once we agree on the API I'll make release a new official version of > AuthCookieDBI with the changes.
Ok, I added what I think is reasonable changes to the base class. I replaced all calls to $r->log_error with a call to $class->logger, however I think there are places in the code where $class is not passed in or is not defined yet because the module will not pass a perl -c test. I think I got you like 85% of the way there though (I hope), and you will only have to make minor changes. Take a look at the attached and let me know before I continue by creating the sub-class. ^C

Message body is not shown because sender requested not to inline it.

Chad, I'm attaching a draft version of AuthCookieDBI.pm for you to try out. I won't be able to work on this again until at least next weekend.
Subject: AuthCookieDBI.pm

Message body is not shown because it is too large.

Subject: Re: [rt.cpan.org #75675] Feature request for mysql logging
Date: Sun, 11 Mar 2012 23:03:57 -0700
To: bug-Apache2-AuthCookieDBI [...] rt.cpan.org
From: Chad <ccolumbu [...] gmail.com>
Ok, FYI: running it returns this: Can't locate object method "log_notice" via package "Apache2::RequestRec" at /usr/local/share/perl5/Apache2/AuthCookieDBI.pm line 1033 I am looking at it now. ^C On 3/11/2012 10:22 PM, Matisse Enzer via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=75675> > > Chad, > > I'm attaching a draft version of AuthCookieDBI.pm for you to try out. > > I won't be able to work on this again until at least next weekend.
Subject: Re: [rt.cpan.org #75675] Feature request for mysql logging
Date: Mon, 12 Mar 2012 01:06:42 -0700
To: bug-Apache2-AuthCookieDBI [...] rt.cpan.org
From: Chad <ccolumbu [...] gmail.com>
On 3/11/2012 10:22 PM, Matisse Enzer via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=75675> > > Chad, > > I'm attaching a draft version of AuthCookieDBI.pm for you to try out. > > I won't be able to work on this again until at least next weekend.
Ok, I fixed the line 1033 problem by adding this to hardcoded line right above it for now (just so I can move on till you are working next weekend): $log_method = 'log_error'; I also changed the my to our on line 301, so I can add to the config vars in the sub-class: our %CONFIG_DEFAULT = ( So I have a working test package now, but it needs a lot more work.