Bugzilla – Attachment 31690 Details for
Bug 12952
Log koha actions to syslog too
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Log koha actions to syslog too
Log-koha-actions-to-syslog-too.patch (text/plain), 5.03 KB, created by
Srdjan Jankovic
on 2014-09-18 02:08:28 UTC
(
hide
)
Description:
Log koha actions to syslog too
Filename:
MIME Type:
Creator:
Srdjan Jankovic
Created:
2014-09-18 02:08:28 UTC
Size:
5.03 KB
patch
obsolete
>From 94f86c41316e3c5db2543ca7f0d655f606b3daab Mon Sep 17 00:00:00 2001 >From: Srdjan <srdjan@catalyst.net.nz> >Date: Tue, 9 Sep 2014 11:14:11 +1200 >Subject: [PATCH] Log koha actions to syslog too > >* Added kohasite and syslog_facility to config >* syslog_facility is set to "user" and commented out for the fresh site > install >* If syslog_facility is enabled in config, log to syslog as <kohasite> > (value of kohasite config) >* /etc/rsyslog.d/99-<kohasite>.conf is created with filter instructions > to direct <kohasite> log entries to standard log dir > (/var/log/koha/<kohasite>) action.log; syslog daemons other than > rsyslog need to be configured (or not) to do the same, otherwise catch > all syslog log file is used > >http://bugs.koha-community.org/show_bug.cgi?id=12952 >--- > C4/Log.pm | 8 ++++++++ > debian/scripts/koha-create | 6 +++++- > debian/scripts/koha-dump | 1 + > debian/scripts/koha-remove | 2 ++ > debian/templates/koha-conf-site.xml.in | 4 ++++ > debian/templates/rsyslog-site.in | 2 ++ > t/Log.t | 1 + > 7 files changed, 23 insertions(+), 1 deletion(-) > create mode 100644 debian/templates/rsyslog-site.in > >diff --git a/C4/Log.pm b/C4/Log.pm >index 80c3493..7e3bbe7 100644 >--- a/C4/Log.pm >+++ b/C4/Log.pm >@@ -26,6 +26,7 @@ use warnings; > > use C4::Context; > use C4::Dates qw(format_date); >+use Sys::Syslog qw(:standard :macros); > > use vars qw($VERSION @ISA @EXPORT); > >@@ -79,6 +80,13 @@ sub logaction { > my $sth=$dbh->prepare("Insert into action_logs (timestamp,user,module,action,object,info) values (now(),?,?,?,?,?)"); > $sth->execute($usernumber,$modulename,$actionname,$objectnumber,$infos); > $sth->finish; >+ >+ my $facility = C4::Context->config("syslog_facility") or return; >+ my $kohasite = C4::Context->config("kohasite"); >+ openlog($kohasite, 'nofatal', $facility); >+ $objectnumber = '' unless defined $objectnumber; >+ syslog(LOG_NOTICE, "$modulename: $actionname ($objectnumber); [$usernumber] $infos"); >+ closelog(); > } > > =item GetLogStatus >diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create >index 6891ac1..5c4aa2a 100755 >--- a/debian/scripts/koha-create >+++ b/debian/scripts/koha-create >@@ -546,8 +546,12 @@ eof > # Generate and install Apache site-available file and log dir. > generate_config_file apache-site.conf.in \ > "/etc/apache2/sites-available/$name.conf" >+ # Generate and install rsyslog conf >+ generate_config_file rsyslog-site.conf.in \ >+ "/etc/rsyslog.d/99-$name.conf" > mkdir "/var/log/koha/$name" >- chown "$username:$username" "/var/log/koha/$name" >+ chown "$username:adm" "/var/log/koha/$name" >+ chmod 0775 "/var/log/koha/$name" > > > # Generate and install main Koha config file. >diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump >index bf4bd5f..23a4b38 100755 >--- a/debian/scripts/koha-dump >+++ b/debian/scripts/koha-dump >@@ -63,6 +63,7 @@ tar -C / -czf "$metadump" \ > "etc/koha/sites/$name" \ > "etc/apache2/sites-available/$instancefile" \ > "etc/apache2/sites-enabled/$instancefile" \ >+ "etc/rsyslog.d/99-$name.conf" \ > "var/lib/koha/$name" \ > "var/log/koha/$name" > >diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove >index 528db75..39e3afd 100755 >--- a/debian/scripts/koha-remove >+++ b/debian/scripts/koha-remove >@@ -81,6 +81,8 @@ eof > > [ -f "$instancefile" ] && \ > rm "$instancefile" >+ [ -f "/etc/rsyslog.d/99-$name.conf" ] && \ >+ rm "/etc/rsyslog.d/99-$name.conf" > [ -f "/etc/koha/sites/$name/koha-conf.xml" ] && \ > rm "/etc/koha/sites/$name/koha-conf.xml" > [ -f "/etc/koha/sites/$name/zebra-biblios.cfg" ] && \ >diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in >index 371b1d2..7506631 100644 >--- a/debian/templates/koha-conf-site.xml.in >+++ b/debian/templates/koha-conf-site.xml.in >@@ -248,6 +248,7 @@ > --> > > <config> >+ <kohasite>__KOHASITE__</kohasite> > <db_scheme>mysql</db_scheme> > <database>__DB_NAME__</database> > <hostname>__DB_HOST__</hostname> >@@ -282,6 +283,9 @@ > <zebra_auth_index_mode>__AUTHORITIES_INDEXING_MODE__</zebra_auth_index_mode> > <zebra_lockdir>/var/lock/koha/__KOHASITE__</zebra_lockdir> > <queryparser_config>/etc/koha/searchengine/queryparser.yaml</queryparser_config> >+ <!-- >+ <syslog_facility>user</syslog_facility> >+ --> > </config> > > </yazgfs> >diff --git a/debian/templates/rsyslog-site.in b/debian/templates/rsyslog-site.in >new file mode 100644 >index 0000000..bd566d3 >--- /dev/null >+++ b/debian/templates/rsyslog-site.in >@@ -0,0 +1,2 @@ >+if $programname == '__KOHASITE__' then /var/log/koha/__KOHASITE__/action.log >+if $programname == '__KOHASITE__' then ~ >diff --git a/t/Log.t b/t/Log.t >index 601b909..d11cd9f 100755 >--- a/t/Log.t >+++ b/t/Log.t >@@ -13,6 +13,7 @@ BEGIN { > use_ok('C4::Log'); > } > >+t::lib::Mocks::mock_config('syslog_facility', 'user'); > t::lib::Mocks::mock_preference('BorrowersLog', 1); > t::lib::Mocks::mock_preference('CataloguingLog', 1); > t::lib::Mocks::mock_preference('IssueLog', 1); >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12952
:
31690
|
31887