[Koha-bugs] [Bug 20750] Allow timestamped auditing of ILL request events
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Wed May 23 15:24:48 CEST 2018
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20750
--- Comment #15 from Andrew Isherwood <andrew.isherwood at ptfs-europe.com> ---
Hi Magnus - Thanks for looking at this. Currently, all this code does is log
status changes. I can see how you might have thought that other stuff was being
logged as, in addition to logging during ->status calls, we also have potential
logging during a ->store call. This was to catch the case where a status was
being set directly in a ->store call, e.g.
->store({ status => 'REQ' })
Which obviously wouldn't have been caught by the logger in the status method.
So, there is potential to log other "things" during the ->store call, but
currently we don't. It is easily added by adding a new element to the
Koha::ILLRequest::Logger $loggers class property:
$self->{loggers} = {
status => sub {
$self->log_status_change(@_);
}
};
[...]
sub log_maybe {
my ($self, $req, $attrs) = @_;
if (defined $req && defined $attrs) {
foreach my $key (keys %{ $attrs }) {
if (defined($self->{loggers}->{$key})) {
$self->{loggers}->{$key}($req, $attrs->{$key});
}
}
}
}
[...]
sub log_status_change {
my ( $self, $req, $new_status ) = @_;
$self->set_data({
actionname => 'STATUS_CHANGE',
objectnumber => $req->id,
infos => to_json({
log_origin => 'core',
status_before => $req->{previous_status},
status_after => $new_status
})
});
$self->log_something();
}
As you can see, currently it says "if we get a call to $request->store and the
thing we're storing contains a 'status' property, log the value of it"
We also provide display templates for when it comes to displaying that stored
"thing" back to the user.
I *have* added a call to the logger in the BLDSS backend whenever an API
request is sent to the BLDSS status check endpoint. It's a very simple addition
and can be seen here:
https://github.com/PTFS-Europe/BLDSS-backend/commit/40a4ccdce6e04293970258797d7a0c4fcb33ff32
I hope this helps :)
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list