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

(-)a/C4/Log.pm (-2 / +19 lines)
Lines 94-102 sub logaction { Link Here
94
        ? basename($0)
94
        ? basename($0)
95
        : undef;
95
        : undef;
96
96
97
    my @trace;
98
    my $depth = C4::Context->preference('ActionLogsTraceDepth') || 0;
99
    for ( my $i = 0 ; $i < $depth ; $i++ ) {
100
        my ( $package, $filename, $line, $subroutine ) = caller($i);
101
        last unless defined $line;
102
        push(
103
            @trace,
104
            {
105
                package    => $package,
106
                filename   => $filename,
107
                line       => $line,
108
                subroutine => $subroutine,
109
            }
110
        );
111
    }
112
    my $trace = @trace ? to_json( \@trace, { utf8 => 1, pretty => 1 } ) : undef;
113
97
    my $dbh = C4::Context->dbh;
114
    my $dbh = C4::Context->dbh;
98
    my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info,interface,script) values (now(),?,?,?,?,?,?,?)");
115
    my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info,interface,script,trace) values (now(),?,?,?,?,?,?,?,?)");
99
    $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos,$interface,$script);
116
    $sth->execute( $usernumber, $modulename, $actionname, $objectnumber, $infos, $interface, $script, $trace );
100
    $sth->finish;
117
    $sth->finish;
101
118
102
    my $logger = Koha::Logger->get(
119
    my $logger = Koha::Logger->get(
(-)a/installer/data/mysql/atomicupdate/bug_32057.pl (+21 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "32057",
5
    description => "Bug 32057 - Add optional stack trace to action logs",
6
    up => sub {
7
        my ($args) = @_;
8
        my $dbh = $args->{dbh};
9
10
        if( !column_exists( 'action_logs', 'trace' ) ) {
11
          $dbh->do(q{
12
              ALTER TABLE action_logs ADD COLUMN `trace` TEXT DEFAULT NULL COMMENT 'An optional stack trace enabled by ActionLogsTraceDepth' AFTER `script`
13
          });
14
        }
15
16
        $dbh->do(q{
17
            INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
18
            ('ActionLogsTraceDepth', '0', '', 'Sets the maximum depth of the action logs stack trace', 'Integer')
19
        });
20
    },
21
}
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 171-176 CREATE TABLE `action_logs` ( Link Here
171
  `info` mediumtext DEFAULT NULL COMMENT 'information about the action (usually includes SQL statement)',
171
  `info` mediumtext DEFAULT NULL COMMENT 'information about the action (usually includes SQL statement)',
172
  `interface` varchar(30) DEFAULT NULL COMMENT 'the context this action was taken in',
172
  `interface` varchar(30) DEFAULT NULL COMMENT 'the context this action was taken in',
173
  `script` varchar(255) DEFAULT NULL COMMENT 'the name of the cron script that caused this change',
173
  `script` varchar(255) DEFAULT NULL COMMENT 'the name of the cron script that caused this change',
174
  `trace` TEXT DEFAULT NULL COMMENT 'An optional stack trace enabled by ActionLogsTraceDepth',
174
  PRIMARY KEY (`action_id`),
175
  PRIMARY KEY (`action_id`),
175
  KEY `timestamp_idx` (`timestamp`),
176
  KEY `timestamp_idx` (`timestamp`),
176
  KEY `user_idx` (`user`),
177
  KEY `user_idx` (`user`),
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 9-14 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
9
('AcquisitionLog','0',NULL,'If ON, log acquisitions activity','YesNo'),
9
('AcquisitionLog','0',NULL,'If ON, log acquisitions activity','YesNo'),
10
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: their own only, any within their branch, or all','Choice'),
10
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: their own only, any within their branch, or all','Choice'),
11
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
11
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
12
('ActionLogsTraceDepth', '0', '', 'Sets the maximum depth of the action logs stack trace', 'Integer'),
12
('AdditionalContentsEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'),
13
('AdditionalContentsEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'),
13
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
14
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
14
('AddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then it will fallback to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault and KohaAdminEmailAddress', 'free'),
15
('AddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then it will fallback to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault and KohaAdminEmailAddress', 'free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref (-1 / +5 lines)
Lines 116-121 Logging: Link Here
116
            - any actions on recalls (create, cancel, expire, fulfill).
116
            - any actions on recalls (create, cancel, expire, fulfill).
117
117
118
    Debugging:
118
    Debugging:
119
        -
120
            - "When logging actions, store a stack trace that goes at most"
121
            - pref: "ActionLogsTraceDepth"
122
              class: integer
123
            - "levels deep."
119
        -
124
        -
120
            - pref: DumpTemplateVarsIntranet
125
            - pref: DumpTemplateVarsIntranet
121
              choices:
126
              choices:
122
- 

Return to bug 32057