|
Lines 2-8
package C4::Log;
Link Here
|
| 2 |
|
2 |
|
| 3 |
#package to deal with Logging Actions in DB |
3 |
#package to deal with Logging Actions in DB |
| 4 |
|
4 |
|
| 5 |
|
|
|
| 6 |
# Copyright 2000-2002 Katipo Communications |
5 |
# Copyright 2000-2002 Katipo Communications |
| 7 |
# Copyright 2011 MJ Ray and software.coop |
6 |
# Copyright 2011 MJ Ray and software.coop |
| 8 |
# |
7 |
# |
|
Lines 24-34
package C4::Log;
Link Here
|
| 24 |
use strict; |
23 |
use strict; |
| 25 |
use warnings; |
24 |
use warnings; |
| 26 |
|
25 |
|
| 27 |
use Data::Dumper qw( Dumper ); |
26 |
use Data::Dumper qw( Dumper ); |
| 28 |
use File::Basename qw( basename ); |
27 |
use File::Basename qw( basename ); |
| 29 |
use JSON qw( to_json encode_json ); |
28 |
use JSON qw( to_json encode_json ); |
| 30 |
use Scalar::Util qw( blessed ); |
29 |
use Scalar::Util qw( blessed ); |
| 31 |
use Struct::Diff qw( diff ); |
30 |
use Struct::Diff qw( diff ); |
| 32 |
|
31 |
|
| 33 |
use C4::Context; |
32 |
use C4::Context; |
| 34 |
use Koha::Logger; |
33 |
use Koha::Logger; |
|
Lines 37-45
use Koha::ActionLogs;
Link Here
|
| 37 |
use vars qw(@ISA @EXPORT); |
36 |
use vars qw(@ISA @EXPORT); |
| 38 |
|
37 |
|
| 39 |
BEGIN { |
38 |
BEGIN { |
| 40 |
require Exporter; |
39 |
require Exporter; |
| 41 |
@ISA = qw(Exporter); |
40 |
@ISA = qw(Exporter); |
| 42 |
@EXPORT = qw(logaction cronlogaction); |
41 |
@EXPORT = qw(logaction cronlogaction); |
| 43 |
} |
42 |
} |
| 44 |
|
43 |
|
| 45 |
=head1 NAME |
44 |
=head1 NAME |
|
Lines 71-103
number is set to 0, which is the same as the superlibrarian's number.
Link Here
|
| 71 |
|
70 |
|
| 72 |
#' |
71 |
#' |
| 73 |
sub logaction { |
72 |
sub logaction { |
| 74 |
my ($modulename, $actionname, $objectnumber, $infos, $interface, $original )=@_; |
73 |
my ( $modulename, $actionname, $objectnumber, $infos, $interface, $original ) = @_; |
| 75 |
|
74 |
|
| 76 |
my $updated; |
75 |
my $updated; |
| 77 |
|
76 |
|
| 78 |
# Get ID of logged in user. if called from a batch job, |
77 |
# Get ID of logged in user. if called from a batch job, |
| 79 |
# no user session exists and C4::Context->userenv() returns |
78 |
# no user session exists and C4::Context->userenv() returns |
| 80 |
# the scalar '0'. |
79 |
# the scalar '0'. |
| 81 |
my $userenv = C4::Context->userenv(); |
80 |
my $userenv = C4::Context->userenv(); |
| 82 |
my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : 0; |
81 |
my $usernumber = ( ref($userenv) eq 'HASH' ) ? $userenv->{'number'} : 0; |
| 83 |
$usernumber ||= 0; |
82 |
$usernumber ||= 0; |
| 84 |
$interface //= C4::Context->interface; |
83 |
$interface //= C4::Context->interface; |
| 85 |
|
84 |
|
| 86 |
if( blessed($infos) && $infos->isa('Koha::Object') ) { |
85 |
if ( blessed($infos) && $infos->isa('Koha::Object') ) { |
| 87 |
$infos = $infos->get_from_storage if $infos->in_storage; |
86 |
$infos = $infos->get_from_storage if $infos->in_storage; |
| 88 |
$updated = $infos->unblessed; |
87 |
$updated = $infos->unblessed; |
| 89 |
local $Data::Dumper::Sortkeys = 1; |
88 |
local $Data::Dumper::Sortkeys = 1; |
| 90 |
|
89 |
|
| 91 |
if ( $infos->isa('Koha::Item') && $modulename eq 'CATALOGUING' && $actionname eq 'MODIFY' ) { |
90 |
if ( $infos->isa('Koha::Item') && $modulename eq 'CATALOGUING' && $actionname eq 'MODIFY' ) { |
| 92 |
$infos = "item " . Dumper( $updated ); |
91 |
$infos = "item " . Dumper($updated); |
| 93 |
} else { |
92 |
} else { |
| 94 |
$infos = Dumper( $updated ); |
93 |
$infos = Dumper($updated); |
| 95 |
} |
94 |
} |
| 96 |
} else { |
95 |
} else { |
| 97 |
$updated = $infos; |
96 |
$updated = $infos; |
| 98 |
} |
97 |
} |
| 99 |
|
98 |
|
| 100 |
my $script = ( $interface eq 'cron' or $interface eq 'commandline' ) |
99 |
my $script = |
|
|
100 |
( $interface eq 'cron' or $interface eq 'commandline' ) |
| 101 |
? basename($0) |
101 |
? basename($0) |
| 102 |
: undef; |
102 |
: undef; |
| 103 |
|
103 |
|
|
Lines 172-182
Logs the path and name of the calling script plus the information privided by pa
Link Here
|
| 172 |
#' |
172 |
#' |
| 173 |
sub cronlogaction { |
173 |
sub cronlogaction { |
| 174 |
my $params = shift; |
174 |
my $params = shift; |
| 175 |
my $info = $params->{info}; |
175 |
my $info = $params->{info}; |
| 176 |
my $action = $params->{action}; |
176 |
my $action = $params->{action}; |
| 177 |
$action ||= "Run"; |
177 |
$action ||= "Run"; |
| 178 |
my $loginfo = (caller(0))[1]; |
178 |
my $loginfo = ( caller(0) )[1]; |
| 179 |
$loginfo .= ' ' . $info if $info; |
179 |
$loginfo .= ' ' . $info if $info; |
| 180 |
logaction( 'CRONJOBS', $action, $$, $loginfo ) if C4::Context->preference('CronjobLog'); |
180 |
logaction( 'CRONJOBS', $action, $$, $loginfo ) if C4::Context->preference('CronjobLog'); |
| 181 |
} |
181 |
} |
| 182 |
|
182 |
|