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.