Lines 49-56
relating to Illrequest to the action log.
Link Here
|
49 |
|
49 |
|
50 |
my $config = Koha::Illrequest::Logger->new(); |
50 |
my $config = Koha::Illrequest::Logger->new(); |
51 |
|
51 |
|
52 |
Create a new Koha::Illrequest::Logger object, with skeleton logging data |
52 |
Create a new Koha::Illrequest::Logger object. |
53 |
We also set up data of 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 |
|
56 |
=cut |
56 |
=cut |
Lines 59-68
sub new {
Link Here
|
59 |
my ( $class ) = @_; |
59 |
my ( $class ) = @_; |
60 |
my $self = {}; |
60 |
my $self = {}; |
61 |
|
61 |
|
62 |
$self->{data} = { |
|
|
63 |
modulename => 'ILL' |
64 |
}; |
65 |
|
66 |
$self->{loggers} = { |
62 |
$self->{loggers} = { |
67 |
status => sub { |
63 |
status => sub { |
68 |
$self->log_status_change(@_); |
64 |
$self->log_status_change(@_); |
Lines 105-111
sub log_maybe {
Link Here
|
105 |
|
101 |
|
106 |
=head3 log_status_change |
102 |
=head3 log_status_change |
107 |
|
103 |
|
108 |
Koha::IllRequest::Logger->log_status_change(); |
104 |
Koha::IllRequest::Logger->log_status_change($req, $new_status); |
109 |
|
105 |
|
110 |
Log a request's status change |
106 |
Log a request's status change |
111 |
|
107 |
|
Lines 114-120
Log a request's status change
Link Here
|
114 |
sub log_status_change { |
110 |
sub log_status_change { |
115 |
my ( $self, $req, $new_status ) = @_; |
111 |
my ( $self, $req, $new_status ) = @_; |
116 |
|
112 |
|
117 |
$self->set_data({ |
113 |
$self->log_something({ |
|
|
114 |
modulename => 'ILL', |
118 |
actionname => 'STATUS_CHANGE', |
115 |
actionname => 'STATUS_CHANGE', |
119 |
objectnumber => $req->id, |
116 |
objectnumber => $req->id, |
120 |
infos => to_json({ |
117 |
infos => to_json({ |
Lines 123-178
sub log_status_change {
Link Here
|
123 |
status_after => $new_status |
120 |
status_after => $new_status |
124 |
}) |
121 |
}) |
125 |
}); |
122 |
}); |
126 |
|
|
|
127 |
$self->log_something(); |
128 |
} |
123 |
} |
129 |
|
124 |
|
130 |
=head3 log_something |
125 |
=head3 log_something |
131 |
|
126 |
|
132 |
Koha::IllRequest::Logger->log_something(); |
127 |
Koha::IllRequest::Logger->log_something({ |
|
|
128 |
modulename => 'ILL', |
129 |
actionname => 'STATUS_CHANGE', |
130 |
objectnumber => $req->id, |
131 |
infos => to_json({ |
132 |
log_origin => 'core', |
133 |
status_before => $req->{previous_status}, |
134 |
status_after => $new_status |
135 |
}) |
136 |
}); |
133 |
|
137 |
|
134 |
If we have the required data set, log an action |
138 |
If we have the required data passed, log an action |
135 |
|
139 |
|
136 |
=cut |
140 |
=cut |
137 |
|
141 |
|
138 |
sub log_something { |
142 |
sub log_something { |
139 |
my ( $self ) = @_; |
143 |
my ( $self, $to_log ) = @_; |
140 |
|
144 |
|
141 |
if ( |
145 |
if ( |
142 |
defined $self->{data}->{modulename} && |
146 |
defined $to_log->{modulename} && |
143 |
defined $self->{data}->{actionname} && |
147 |
defined $to_log->{actionname} && |
144 |
defined $self->{data}->{objectnumber} && |
148 |
defined $to_log->{objectnumber} && |
145 |
defined $self->{data}->{infos} && |
149 |
defined $to_log->{infos} && |
146 |
C4::Context->preference("IllLog") |
150 |
C4::Context->preference("IllLog") |
147 |
) { |
151 |
) { |
148 |
logaction( |
152 |
logaction( |
149 |
$self->{data}->{modulename}, |
153 |
$to_log->{modulename}, |
150 |
$self->{data}->{actionname}, |
154 |
$to_log->{actionname}, |
151 |
$self->{data}->{objectnumber}, |
155 |
$to_log->{objectnumber}, |
152 |
$self->{data}->{infos} |
156 |
$to_log->{infos} |
153 |
); |
157 |
); |
154 |
} |
158 |
} |
155 |
} |
159 |
} |
156 |
|
160 |
|
157 |
=head3 set_data |
|
|
158 |
|
159 |
Koha::IllRequest::Logger->set_data({ |
160 |
key => 'value', |
161 |
key2 => 'value2' |
162 |
}); |
163 |
|
164 |
Set arbitrary data propert(ies) on the logger object |
165 |
|
166 |
=cut |
167 |
|
168 |
sub set_data { |
169 |
my ( $self, $data ) = @_; |
170 |
|
171 |
foreach my $key (keys %{ $data }) { |
172 |
$self->{data}->{$key} = $data->{$key}; |
173 |
} |
174 |
} |
175 |
|
176 |
=head3 get_log_template |
161 |
=head3 get_log_template |
177 |
|
162 |
|
178 |
$template_path = get_log_template($origin, $action); |
163 |
$template_path = get_log_template($origin, $action); |