View | Details | Raw Unified | Return to bug 35581
Collapse All | Expand All

(-)a/Koha/ILL/Batch.pm (-4 / +4 lines)
Lines 22-28 use Modern::Perl; Link Here
22
use Koha::Database;
22
use Koha::Database;
23
23
24
use Koha::Illrequests;
24
use Koha::Illrequests;
25
use Koha::Illrequest::Logger;
25
use Koha::ILL::Request::Logger;
26
use Koha::ILL::Batch::Statuses;
26
use Koha::ILL::Batch::Statuses;
27
use Koha::Libraries;
27
use Koha::Libraries;
28
use Koha::Patrons;
28
use Koha::Patrons;
Lines 104-110 sub create_and_log { Link Here
104
104
105
    $self->store;
105
    $self->store;
106
106
107
    my $logger = Koha::Illrequest::Logger->new;
107
    my $logger = Koha::ILL::Request::Logger->new;
108
108
109
    $logger->log_something(
109
    $logger->log_something(
110
        {
110
        {
Lines 140-146 sub update_and_log { Link Here
140
        library_id => $self->library_id,
140
        library_id => $self->library_id,
141
    };
141
    };
142
142
143
    my $logger = Koha::Illrequest::Logger->new;
143
    my $logger = Koha::ILL::Request::Logger->new;
144
144
145
    $logger->log_something(
145
    $logger->log_something(
146
        {
146
        {
Lines 168-174 Log batch delete Link Here
168
sub delete_and_log {
168
sub delete_and_log {
169
    my ($self) = @_;
169
    my ($self) = @_;
170
170
171
    my $logger = Koha::Illrequest::Logger->new;
171
    my $logger = Koha::ILL::Request::Logger->new;
172
172
173
    $logger->log_something(
173
    $logger->log_something(
174
        {
174
        {
(-)a/Koha/ILL/Batch/Status.pm (-4 / +4 lines)
Lines 19-25 package Koha::ILL::Batch::Status; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Koha::Database;
21
use Koha::Database;
22
use Koha::Illrequest::Logger;
22
use Koha::ILL::Request::Logger;
23
use Koha::ILL::Batch;
23
use Koha::ILL::Batch;
24
use JSON qw( to_json );
24
use JSON qw( to_json );
25
use base qw(Koha::Object);
25
use base qw(Koha::Object);
Lines 59-65 sub create_and_log { Link Here
59
        }
59
        }
60
    )->store;
60
    )->store;
61
61
62
    my $logger = Koha::Illrequest::Logger->new;
62
    my $logger = Koha::ILL::Request::Logger->new;
63
63
64
    $logger->log_something(
64
    $logger->log_something(
65
        {
65
        {
Lines 90-96 sub update_and_log { Link Here
90
90
91
    my $after = { name => $self->name };
91
    my $after = { name => $self->name };
92
92
93
    my $logger = Koha::Illrequest::Logger->new;
93
    my $logger = Koha::ILL::Request::Logger->new;
94
94
95
    $logger->log_something(
95
    $logger->log_something(
96
        {
96
        {
Lines 127-133 sub delete_and_log { Link Here
127
    my $affected = Koha::ILL::Batches->search( { status_code => $self->code } );
127
    my $affected = Koha::ILL::Batches->search( { status_code => $self->code } );
128
    $affected->update( { status_code => 'UNKNOWN' } );
128
    $affected->update( { status_code => 'UNKNOWN' } );
129
129
130
    my $logger = Koha::Illrequest::Logger->new;
130
    my $logger = Koha::ILL::Request::Logger->new;
131
131
132
    $logger->log_something(
132
    $logger->log_something(
133
        {
133
        {
(-)a/Koha/Illrequest/Logger.pm (-9 / +9 lines)
Lines 1-4 Link Here
1
package Koha::Illrequest::Logger;
1
package Koha::ILL::Request::Logger;
2
2
3
# Copyright 2018 PTFS Europe Ltd
3
# Copyright 2018 PTFS Europe Ltd
4
#
4
#
Lines 29-35 use Koha::Notice::Template; Link Here
29
29
30
=head1 NAME
30
=head1 NAME
31
31
32
Koha::Illrequest::Logger - Koha ILL Action / Event logger
32
Koha::ILL::ILL::Request::Logger - Koha ILL Action / Event logger
33
33
34
=head1 SYNOPSIS
34
=head1 SYNOPSIS
35
35
Lines 47-55 relating to Illrequest to the action log. Link Here
47
47
48
=head3 new
48
=head3 new
49
49
50
    my $config = Koha::Illrequest::Logger->new();
50
    my $config = Koha::ILL::Request::Logger->new();
51
51
52
Create a new Koha::Illrequest::Logger object.
52
Create a new Koha::ILL::Request::Logger object .
53
We also set up what can be logged, how to do it and how to display
53
We also set up what can be logged, how to do it and how to display
54
log entries we get back out
54
log entries we get back out
55
55
Lines 84-90 sub new { Link Here
84
84
85
=head3 log_maybe
85
=head3 log_maybe
86
86
87
    Koha::IllRequest::Logger->log_maybe($params);
87
    Koha::ILL::Request::Logger->log_maybe($params);
88
88
89
Receive params hashref, containing a request object and an attrs
89
Receive params hashref, containing a request object and an attrs
90
hashref (which may or may not be defined) If the attrs hashref contains
90
hashref (which may or may not be defined) If the attrs hashref contains
Lines 109-115 sub log_maybe { Link Here
109
109
110
=head3 log_patron_notice
110
=head3 log_patron_notice
111
111
112
    Koha::IllRequest::Logger->log_patron_notice($params);
112
    Koha::ILL::Request::Logger->log_patron_notice($params);
113
113
114
Receive a hashref containing a request object and params to log,
114
Receive a hashref containing a request object and params to log,
115
and log it
115
and log it
Lines 134-140 sub log_patron_notice { Link Here
134
134
135
=head3 log_status_change
135
=head3 log_status_change
136
136
137
    Koha::IllRequest::Logger->log_status_change($params);
137
    Koha::ILL::Request::Logger->log_status_change($params);
138
138
139
Receive a hashref containing a request object and a status to log,
139
Receive a hashref containing a request object and a status to log,
140
and log it
140
and log it
Lines 160-166 sub log_status_change { Link Here
160
160
161
=head3 log_something
161
=head3 log_something
162
162
163
    Koha::IllRequest::Logger->log_something({
163
    Koha::ILL::Request::Logger->log_something({
164
        modulename   => 'ILL',
164
        modulename   => 'ILL',
165
        actionname   => 'STATUS_CHANGE',
165
        actionname   => 'STATUS_CHANGE',
166
        objectnumber => $req->id,
166
        objectnumber => $req->id,
Lines 226-232 sub get_log_template { Link Here
226
226
227
=head3 get_request_logs
227
=head3 get_request_logs
228
228
229
    $requestlogs = Koha::IllRequest::Logger->get_request_logs($request_id);
229
    $requestlogs = Koha::ILL::Request::Logger->get_request_logs($request_id);
230
230
231
Get all logged actions for a given request
231
Get all logged actions for a given request
232
232
(-)a/Koha/Illrequest.pm (-8 / +8 lines)
Lines 33-39 use Koha::Exceptions::Ill; Link Here
33
use Koha::ILL::Comments;
33
use Koha::ILL::Comments;
34
use Koha::ILL::Request::Attributes;
34
use Koha::ILL::Request::Attributes;
35
use Koha::AuthorisedValue;
35
use Koha::AuthorisedValue;
36
use Koha::Illrequest::Logger;
36
use Koha::ILL::Request::Logger;
37
use Koha::Patron;
37
use Koha::Patron;
38
use Koha::ILL::Batches;
38
use Koha::ILL::Batches;
39
use Koha::AuthorisedValues;
39
use Koha::AuthorisedValues;
Lines 234-240 sub comments { Link Here
234
234
235
sub logs {
235
sub logs {
236
    my ( $self ) = @_;
236
    my ( $self ) = @_;
237
    my $logger = Koha::Illrequest::Logger->new;
237
    my $logger = Koha::ILL::Request::Logger->new;
238
    return $logger->get_request_logs($self);
238
    return $logger->get_request_logs($self);
239
}
239
}
240
240
Lines 317-323 sub status_alias { Link Here
317
        my $ret = $self->SUPER::status_alias($val);
317
        my $ret = $self->SUPER::status_alias($val);
318
        my $val_to_log = $val ? $new_status_alias : scalar $self->status;
318
        my $val_to_log = $val ? $new_status_alias : scalar $self->status;
319
        if ($ret) {
319
        if ($ret) {
320
            my $logger = Koha::Illrequest::Logger->new;
320
            my $logger = Koha::ILL::Request::Logger->new;
321
            $logger->log_status_change({
321
            $logger->log_status_change({
322
                request => $self,
322
                request => $self,
323
                value   => $val_to_log
323
                value   => $val_to_log
Lines 379-385 sub status { Link Here
379
            # so we pass -1, which is special cased in the overloaded setter
379
            # so we pass -1, which is special cased in the overloaded setter
380
            $self->status_alias("-1");
380
            $self->status_alias("-1");
381
        } else {
381
        } else {
382
            my $logger = Koha::Illrequest::Logger->new;
382
            my $logger = Koha::ILL::Request::Logger->new;
383
            $logger->log_status_change({
383
            $logger->log_status_change({
384
                request => $self,
384
                request => $self,
385
                value   => $new_status
385
                value   => $new_status
Lines 442-448 sub load_backend { Link Here
442
        $self->{_my_backend} = $backend_plugin->new_ill_backend(
442
        $self->{_my_backend} = $backend_plugin->new_ill_backend(
443
            {
443
            {
444
                config => $self->_config,
444
                config => $self->_config,
445
                logger => Koha::Illrequest::Logger->new
445
                logger => Koha::ILL::Request::Logger->new
446
            }
446
            }
447
        );
447
        );
448
    } elsif ($backend_name) {
448
    } elsif ($backend_name) {
Lines 455-461 sub load_backend { Link Here
455
        $self->{_my_backend} = $backend_class->new(
455
        $self->{_my_backend} = $backend_class->new(
456
            {
456
            {
457
                config => $self->_config,
457
                config => $self->_config,
458
                logger => Koha::Illrequest::Logger->new
458
                logger => Koha::ILL::Request::Logger->new
459
            }
459
            }
460
        );
460
        );
461
    }
461
    }
Lines 1673-1679 sub send_patron_notice { Link Here
1673
        }
1673
        }
1674
    }
1674
    }
1675
    if (scalar @success > 0) {
1675
    if (scalar @success > 0) {
1676
        my $logger = Koha::Illrequest::Logger->new;
1676
        my $logger = Koha::ILL::Request::Logger->new;
1677
        $logger->log_patron_notice({
1677
        $logger->log_patron_notice({
1678
            request => $self,
1678
            request => $self,
1679
            notice_code => $notice_code
1679
            notice_code => $notice_code
Lines 1919-1925 sub store { Link Here
1919
    $attrs->{log_origin} = 'core';
1919
    $attrs->{log_origin} = 'core';
1920
1920
1921
    if ($ret && defined $attrs) {
1921
    if ($ret && defined $attrs) {
1922
        my $logger = Koha::Illrequest::Logger->new;
1922
        my $logger = Koha::ILL::Request::Logger->new;
1923
        $logger->log_maybe({
1923
        $logger->log_maybe({
1924
            request => $self,
1924
            request => $self,
1925
            attrs   => $attrs
1925
            attrs   => $attrs
(-)a/t/db_dependent/Koha/ILL/Batch/Statuses.t (-1 / +1 lines)
Lines 47-53 my $effects = { Link Here
47
};
47
};
48
48
49
# Mock a logger so we can check it is called
49
# Mock a logger so we can check it is called
50
my $logger = Test::MockModule->new('Koha::Illrequest::Logger');
50
my $logger = Test::MockModule->new('Koha::ILL::Request::Logger');
51
$logger->mock(
51
$logger->mock(
52
    'log_something',
52
    'log_something',
53
    sub {
53
    sub {
(-)a/t/db_dependent/Illrequest/Logger.t (-4 / +3 lines)
Lines 34-40 my $c4_tpl = Test::MockModule->new('C4::Templates'); Link Here
34
$c4_tpl->mock('_get_template_file',
34
$c4_tpl->mock('_get_template_file',
35
    sub { return ('htdocs', 'theme', 'lang', 'base/'); });
35
    sub { return ('htdocs', 'theme', 'lang', 'base/'); });
36
36
37
use_ok('Koha::Illrequest::Logger');
37
use_ok('Koha::ILL::Request::Logger');
38
38
39
subtest 'Basics' => sub {
39
subtest 'Basics' => sub {
40
40
Lines 42-53 subtest 'Basics' => sub { Link Here
42
42
43
    $schema->storage->txn_begin;
43
    $schema->storage->txn_begin;
44
44
45
    my $logger = Koha::Illrequest::Logger->new;
45
    my $logger = Koha::ILL::Request::Logger->new;
46
46
47
    # new()
47
    # new()
48
    #
48
    #
49
    ok( defined($logger), 'new() returned something' );
49
    ok( defined($logger), 'new() returned something' );
50
    ok( $logger->isa('Koha::Illrequest::Logger'),
50
    ok( $logger->isa('Koha::ILL::Request::Logger'),
51
        'new() returns the correct object' );
51
        'new() returns the correct object' );
52
52
53
    # This is an incomplete data hashref, we use it to
53
    # This is an incomplete data hashref, we use it to
54
- 

Return to bug 35581