|
Lines 20-27
package C4::Log;
Link Here
|
| 20 |
# You should have received a copy of the GNU General Public License |
20 |
# You should have received a copy of the GNU General Public License |
| 21 |
# along with Koha; if not, see <https://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <https://www.gnu.org/licenses>. |
| 22 |
|
22 |
|
| 23 |
use strict; |
23 |
use Modern::Perl; |
| 24 |
use warnings; |
|
|
| 25 |
|
24 |
|
| 26 |
use Data::Dumper qw( Dumper ); |
25 |
use Data::Dumper qw( Dumper ); |
| 27 |
use File::Basename qw( basename ); |
26 |
use File::Basename qw( basename ); |
|
Lines 29-37
use JSON qw( to_json encode_json );
Link Here
|
| 29 |
use Scalar::Util qw( blessed ); |
28 |
use Scalar::Util qw( blessed ); |
| 30 |
use Struct::Diff qw( diff ); |
29 |
use Struct::Diff qw( diff ); |
| 31 |
|
30 |
|
| 32 |
use C4::Context; |
|
|
| 33 |
use Koha::Logger; |
31 |
use Koha::Logger; |
| 34 |
use Koha::ActionLogs; |
32 |
use Koha::ActionLogs; |
|
|
33 |
use Koha::Context::UserEnv; |
| 34 |
use Koha::Context::Interface; |
| 35 |
use Koha::Context::Preferences; |
| 35 |
|
36 |
|
| 36 |
use vars qw(@ISA @EXPORT); |
37 |
use vars qw(@ISA @EXPORT); |
| 37 |
|
38 |
|
|
Lines 77-86
sub logaction {
Link Here
|
| 77 |
# Get ID of logged in user. if called from a batch job, |
78 |
# Get ID of logged in user. if called from a batch job, |
| 78 |
# no user session exists and C4::Context->userenv() returns |
79 |
# no user session exists and C4::Context->userenv() returns |
| 79 |
# the scalar '0'. |
80 |
# the scalar '0'. |
| 80 |
my $userenv = C4::Context->userenv(); |
81 |
my $usernumber = Koha::Context::UserEnv->exists ? Koha::Context::UserEnv->get('number') : 0; |
| 81 |
my $usernumber = ( ref($userenv) eq 'HASH' ) ? $userenv->{'number'} : 0; |
|
|
| 82 |
$usernumber ||= 0; |
82 |
$usernumber ||= 0; |
| 83 |
$interface //= C4::Context->interface; |
83 |
$interface //= Koha::Context::Interface->get_interface(); |
| 84 |
|
84 |
|
| 85 |
if ( blessed($infos) && $infos->isa('Koha::Object') ) { |
85 |
if ( blessed($infos) && $infos->isa('Koha::Object') ) { |
| 86 |
$infos = $infos->get_from_storage if $infos->in_storage; |
86 |
$infos = $infos->get_from_storage if $infos->in_storage; |
|
Lines 102-108
sub logaction {
Link Here
|
| 102 |
: undef; |
102 |
: undef; |
| 103 |
|
103 |
|
| 104 |
my @trace; |
104 |
my @trace; |
| 105 |
my $depth = C4::Context->preference('ActionLogsTraceDepth') || 0; |
105 |
my $depth = Koha::Context::Preferences->get_value('ActionLogsTraceDepth') || 0; |
| 106 |
for ( my $i = 0 ; $i < $depth ; $i++ ) { |
106 |
for ( my $i = 0 ; $i < $depth ; $i++ ) { |
| 107 |
my ( $package, $filename, $line, $subroutine ) = caller($i); |
107 |
my ( $package, $filename, $line, $subroutine ) = caller($i); |
| 108 |
last unless defined $line; |
108 |
last unless defined $line; |
|
Lines 193-199
sub cronlogaction {
Link Here
|
| 193 |
$action ||= "Run"; |
193 |
$action ||= "Run"; |
| 194 |
my $loginfo = ( caller(0) )[1]; |
194 |
my $loginfo = ( caller(0) )[1]; |
| 195 |
$loginfo .= ' ' . $info if $info; |
195 |
$loginfo .= ' ' . $info if $info; |
| 196 |
logaction( 'CRONJOBS', $action, $$, $loginfo ) if C4::Context->preference('CronjobLog'); |
196 |
logaction( 'CRONJOBS', $action, $$, $loginfo ) if Koha::Context::Preferences->get_value('CronjobLog'); |
| 197 |
} |
197 |
} |
| 198 |
|
198 |
|
| 199 |
1; |
199 |
1; |
| 200 |
- |
|
|