|
Lines 79-99
sub new {
Link Here
|
| 79 |
|
79 |
|
| 80 |
=head3 log_maybe |
80 |
=head3 log_maybe |
| 81 |
|
81 |
|
| 82 |
Koha::IllRequest::Logger->log_maybe($attrs); |
82 |
Koha::IllRequest::Logger->log_maybe($params); |
| 83 |
|
83 |
|
| 84 |
Receive request object and an attributes hashref (which may or may |
84 |
Receive params hashref, containing a request object and an attrs |
| 85 |
not be defined) If the hashref contains a key matching our "loggers" hashref |
85 |
hashref (which may or may not be defined) If the attrs hashref contains |
| 86 |
then we want to log it |
86 |
a key matching our "loggers" hashref then we want to log it |
| 87 |
|
87 |
|
| 88 |
=cut |
88 |
=cut |
| 89 |
|
89 |
|
| 90 |
sub log_maybe { |
90 |
sub log_maybe { |
| 91 |
my ($self, $req, $attrs) = @_; |
91 |
my ($self, $params) = @_; |
| 92 |
|
92 |
|
| 93 |
if (defined $req && defined $attrs) { |
93 |
if (defined $params->{request} && defined $params->{attrs}) { |
| 94 |
foreach my $key (keys %{ $attrs }) { |
94 |
foreach my $key (keys %{ $params->{attrs} }) { |
| 95 |
if (defined($self->{loggers}->{$key})) { |
95 |
if (defined($self->{loggers}->{$key})) { |
| 96 |
$self->{loggers}->{$key}($req, $attrs->{$key}); |
96 |
$self->{loggers}->{$key}( |
|
|
97 |
$params->{request}, |
| 98 |
$params->{attrs}->{$key} |
| 99 |
); |
| 97 |
} |
100 |
} |
| 98 |
} |
101 |
} |
| 99 |
} |
102 |
} |
|
Lines 101-125
sub log_maybe {
Link Here
|
| 101 |
|
104 |
|
| 102 |
=head3 log_status_change |
105 |
=head3 log_status_change |
| 103 |
|
106 |
|
| 104 |
Koha::IllRequest::Logger->log_status_change($req, $new_status); |
107 |
Koha::IllRequest::Logger->log_status_change($params); |
| 105 |
|
108 |
|
| 106 |
Log a request's status change |
109 |
Receive a hashref containing a request object and a status to log, |
|
|
110 |
and log it |
| 107 |
|
111 |
|
| 108 |
=cut |
112 |
=cut |
| 109 |
|
113 |
|
| 110 |
sub log_status_change { |
114 |
sub log_status_change { |
| 111 |
my ( $self, $req, $new_status ) = @_; |
115 |
my ( $self, $params ) = @_; |
| 112 |
|
116 |
|
| 113 |
$self->log_something({ |
117 |
if (defined $params->{request} && defined $params->{value}) { |
| 114 |
modulename => 'ILL', |
118 |
$self->log_something({ |
| 115 |
actionname => 'STATUS_CHANGE', |
119 |
modulename => 'ILL', |
| 116 |
objectnumber => $req->id, |
120 |
actionname => 'STATUS_CHANGE', |
| 117 |
infos => to_json({ |
121 |
objectnumber => $params->{request}->id, |
| 118 |
log_origin => 'core', |
122 |
infos => to_json({ |
| 119 |
status_before => $req->{previous_status}, |
123 |
log_origin => 'core', |
| 120 |
status_after => $new_status |
124 |
status_before => $params->{request}->{previous_status}, |
| 121 |
}) |
125 |
status_after => $params->{value} |
| 122 |
}); |
126 |
}) |
|
|
127 |
}); |
| 128 |
} |
| 123 |
} |
129 |
} |
| 124 |
|
130 |
|
| 125 |
=head3 log_something |
131 |
=head3 log_something |
|
Lines 160-173
sub log_something {
Link Here
|
| 160 |
|
166 |
|
| 161 |
=head3 get_log_template |
167 |
=head3 get_log_template |
| 162 |
|
168 |
|
| 163 |
$template_path = get_log_template($origin, $action); |
169 |
$template_path = get_log_template($params); |
| 164 |
|
170 |
|
| 165 |
Given a log's origin and action, get the appropriate display template |
171 |
Given a log's origin and action, get the appropriate display template |
| 166 |
|
172 |
|
| 167 |
=cut |
173 |
=cut |
| 168 |
|
174 |
|
| 169 |
sub get_log_template { |
175 |
sub get_log_template { |
| 170 |
my ($self, $req, $params) = @_; |
176 |
my ($self, $params) = @_; |
| 171 |
|
177 |
|
| 172 |
my $origin = $params->{origin}; |
178 |
my $origin = $params->{origin}; |
| 173 |
my $action = $params->{action}; |
179 |
my $action = $params->{action}; |
|
Lines 179-185
sub get_log_template {
Link Here
|
| 179 |
} else { |
185 |
} else { |
| 180 |
# It's probably a backend log, so we need to get the path to the |
186 |
# It's probably a backend log, so we need to get the path to the |
| 181 |
# template from the backend |
187 |
# template from the backend |
| 182 |
my $backend =$req->{_my_backend}; |
188 |
my $backend =$params->{request}->{_my_backend}; |
| 183 |
return $backend->get_log_template_path($action); |
189 |
return $backend->get_log_template_path($action); |
| 184 |
} |
190 |
} |
| 185 |
} |
191 |
} |
|
Lines 212-224
sub get_request_logs {
Link Here
|
| 212 |
foreach my $log(@{$logs}) { |
218 |
foreach my $log(@{$logs}) { |
| 213 |
$log->{aliases} = $alias_hash; |
219 |
$log->{aliases} = $alias_hash; |
| 214 |
$log->{info} = from_json($log->{info}); |
220 |
$log->{info} = from_json($log->{info}); |
| 215 |
$log->{template} = $self->get_log_template( |
221 |
$log->{template} = $self->get_log_template({ |
| 216 |
$request, |
222 |
request => $request, |
| 217 |
{ |
223 |
origin => $log->{info}->{log_origin}, |
| 218 |
origin => $log->{info}->{log_origin}, |
224 |
action => $log->{action} |
| 219 |
action => $log->{action} |
225 |
}); |
| 220 |
} |
|
|
| 221 |
); |
| 222 |
} |
226 |
} |
| 223 |
|
227 |
|
| 224 |
return $logs; |
228 |
return $logs; |