***SPAM*** [OpenSRF-GIT] OpenSRF branch master updated. 54da75bd2f045dbd2225317f74dc5fe38f415fe5
Evergreen Git
git at git.evergreen-ils.org
Wed Aug 20 17:08:15 EDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".
The branch, master has been updated
via 54da75bd2f045dbd2225317f74dc5fe38f415fe5 (commit)
via 2f4ed86a136cfb7547f7e8c3e2109f4473139276 (commit)
via 512f77b4652d6c793c21c7b6955480e6b9ada195 (commit)
from 6c3b1001c6183b2f633d0f43ccd3d28071c0c48d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 54da75bd2f045dbd2225317f74dc5fe38f415fe5
Author: Galen Charlton <gmc at esilibrary.com>
Date: Wed Aug 20 14:00:17 2014 -0700
LP#1343578: document <logtag> in the example opensrf_core.xml
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/examples/opensrf_core.xml.example b/examples/opensrf_core.xml.example
index 30a94fa..aacf933 100644
--- a/examples/opensrf_core.xml.example
+++ b/examples/opensrf_core.xml.example
@@ -55,6 +55,12 @@ vim:et:ts=2:sw=2:
<syslog>local2</syslog>
<actlog>local1</actlog>
-->
+ <!-- Optional log tag. You can use this to help distinguish
+ syslog entries when running multiple OpenSRF stacks on the
+ same server. -->
+ <!--
+ <logtag>instance1</logtag>
+ -->
<!-- 0 None, 1 Error, 2 Warning, 3 Info, 4 debug, 5 Internal (Nasty) -->
<loglevel>3</loglevel>
@@ -118,6 +124,9 @@ vim:et:ts=2:sw=2:
<logfile>syslog</logfile>
<syslog>local2</syslog>
-->
+ <!--
+ <logtag>instance1</logtag>
+ -->
<loglevel>2</loglevel>
</router>
<router> <!-- private router -->
@@ -140,6 +149,9 @@ vim:et:ts=2:sw=2:
<logfile>syslog</logfile>
<syslog>local2</syslog>
-->
+ <!--
+ <logtag>instance1</logtag>
+ -->
<loglevel>4</loglevel>
</router>
</routers>
commit 2f4ed86a136cfb7547f7e8c3e2109f4473139276
Author: Bill Erickson <berick at esilibrary.com>
Date: Thu Jul 17 15:10:35 2014 -0400
LP#1343578: Perl/C syslog "logtag" additions.
* Honor logtag value when applying a default appname for Perl and C
* Extract / apply logtag in the router
* Minor repair: avoid redundant strdup
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/src/libopensrf/log.c b/src/libopensrf/log.c
index 1bb2747..7954e72 100644
--- a/src/libopensrf/log.c
+++ b/src/libopensrf/log.c
@@ -605,7 +605,7 @@ static void _osrfLogToFile( const char* label, long pid, const char* filename, i
return; // No log file defined
if(!_osrfLogAppname)
- _osrfLogAppname = strdup("osrf"); // apply default application name
+ osrfLogSetAppname("osrf"); // apply default application name
char datebuf[36];
time_t t = time(NULL);
diff --git a/src/libopensrf/osrf_system.c b/src/libopensrf/osrf_system.c
index 7a95819..684dd0d 100644
--- a/src/libopensrf/osrf_system.c
+++ b/src/libopensrf/osrf_system.c
@@ -395,7 +395,7 @@ int osrfSystemBootstrapClientResc( const char* config_file,
if(log_level) llevel = atoi(log_level);
if(!strcmp(log_file, "syslog")) {
- if(logtag) osrfLogSetLogTag(strdup(logtag));
+ if(logtag) osrfLogSetLogTag(logtag);
osrfLogInit( OSRF_LOG_TYPE_SYSLOG, contextnode, llevel );
osrfLogSetSyslogFacility(osrfLogFacilityToInt(facility));
if(actlog) osrfLogSetSyslogActFacility(osrfLogFacilityToInt(actlog));
diff --git a/src/perl/lib/OpenSRF/Utils/Logger.pm b/src/perl/lib/OpenSRF/Utils/Logger.pm
index 77c8593..4798812 100644
--- a/src/perl/lib/OpenSRF/Utils/Logger.pm
+++ b/src/perl/lib/OpenSRF/Utils/Logger.pm
@@ -34,8 +34,8 @@ my $logfile; # log file
my $facility; # syslog facility
my $actfac; # activity log syslog facility
my $actfile; # activity log file
-my $service = $0; # default service name
-my $service_tag = ''; # default service name
+my $service; # syslog service name. default provided below.
+my $service_tag = ''; # default service tag
my $syslog_enabled = 0; # is syslog enabled?
my $act_syslog_enabled = 0; # is syslog enabled?
my $logfile_enabled = 1; # are we logging to a file?
@@ -236,6 +236,9 @@ sub _log_message {
my( $msg, $level ) = @_;
return if $level > $loglevel;
+ # apply a sane default service name/tag
+ $logger->set_service($0) unless $service;
+
my $l; my $n;
my $fac = $facility;
diff --git a/src/router/osrf_router_main.c b/src/router/osrf_router_main.c
index 5e51062..b7b64e2 100644
--- a/src/router/osrf_router_main.c
+++ b/src/router/osrf_router_main.c
@@ -256,6 +256,7 @@ static void setupRouter( const jsonObject* configChunk, int configPos ) {
const char* level = jsonObjectGetString( jsonObjectGetKeyConst( configChunk, "loglevel" ));
const char* log_file = jsonObjectGetString( jsonObjectGetKeyConst( configChunk, "logfile" ));
+ const char* log_tag = jsonObjectGetString( jsonObjectGetKeyConst( configChunk, "logtag" ));
const char* facility = jsonObjectGetString( jsonObjectGetKeyConst( configChunk, "syslog" ));
int llevel = 1;
@@ -268,6 +269,7 @@ static void setupRouter( const jsonObject* configChunk, int configPos ) {
}
if(!strcmp(log_file, "syslog")) {
+ if(log_tag) osrfLogSetLogTag(log_tag);
osrfLogInit( OSRF_LOG_TYPE_SYSLOG, "router", llevel );
osrfLogSetSyslogFacility(osrfLogFacilityToInt(facility));
commit 512f77b4652d6c793c21c7b6955480e6b9ada195
Author: Mike Rylander <mrylander at gmail.com>
Date: Fri Jun 20 15:52:47 2014 -0400
LP#1343578: Add support for log tagging
The ability to provide instance-specific log tagging via syslog
would make running multiple instances much easier to manage. So
this branch does that.
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/include/opensrf/log.h b/include/opensrf/log.h
index 78ba808..c960afc 100644
--- a/include/opensrf/log.h
+++ b/include/opensrf/log.h
@@ -75,6 +75,8 @@ extern "C" {
void osrfLogInit( int type, const char* appname, int maxlevel );
+void osrfLogSetLogTag( const char* logtag );
+
void osrfLogSetSyslogFacility( int facility );
void osrfLogSetSyslogActFacility( int facility );
diff --git a/src/libopensrf/log.c b/src/libopensrf/log.c
index 27eb6f3..1bb2747 100644
--- a/src/libopensrf/log.c
+++ b/src/libopensrf/log.c
@@ -22,6 +22,7 @@ static int _osrfLogActFacility = LOG_LOCAL1;
static char* _osrfLogFile = NULL;
/** Application name. This string will preface every log message. */
static char* _osrfLogAppname = NULL;
+static char* _osrfLogTag = NULL;
/** Maximum message level. Messages of higher levels will be suppressed.
Default: OSRF_LOG_INFO. */
static int _osrfLogLevel = OSRF_LOG_INFO;
@@ -53,6 +54,9 @@ static void _osrfLogSetXid( const char* xid );
- log type (reset to OSRF_LOG_TYPE_STDERR)
*/
void osrfLogCleanup( void ) {
+ if (_osrfLogTag)
+ free(_osrfLogTag);
+ _osrfLogTag = NULL;
free(_osrfLogAppname);
_osrfLogAppname = NULL;
free(_osrfLogFile);
@@ -278,8 +282,16 @@ void osrfLogSetActivityEnabled( int enabled ) {
*/
void osrfLogSetAppname( const char* appname ) {
if(!appname) return;
+
+ char buf[256];
+ if(_osrfLogTag) {
+ snprintf(buf, sizeof(buf), "%s/%s", appname, _osrfLogTag);
+ } else {
+ snprintf(buf, sizeof(buf), "%s", appname);
+ }
+
if(_osrfLogAppname) free(_osrfLogAppname);
- _osrfLogAppname = strdup(appname);
+ _osrfLogAppname = strdup(buf);
/* if syslogging, re-open the log with the appname */
if( _osrfLogType == OSRF_LOG_TYPE_SYSLOG) {
@@ -301,6 +313,19 @@ void osrfLogSetSyslogFacility( int facility ) {
}
/**
+ @brief Store an arbitrary program name tag for future use.
+ @param logtag The string to be stored.
+
+ A log tag is a short string that is appended to the appname
+ we log under. This can be used to segregate logs from different
+ users in, for instance, rsyslogd.
+*/
+
+void osrfLogSetLogTag( const char* logtag ) {
+ if (logtag) _osrfLogTag = strdup(logtag);
+}
+
+/**
@brief Store a facility number for future use for activity messages.
@param facility The facility number to be stored.
diff --git a/src/libopensrf/osrf_system.c b/src/libopensrf/osrf_system.c
index f201a15..7a95819 100644
--- a/src/libopensrf/osrf_system.c
+++ b/src/libopensrf/osrf_system.c
@@ -381,6 +381,7 @@ int osrfSystemBootstrapClientResc( const char* config_file,
char* unixpath = osrfConfigGetValue( NULL, "/unixpath" );
char* facility = osrfConfigGetValue( NULL, "/syslog" );
char* actlog = osrfConfigGetValue( NULL, "/actlog" );
+ char* logtag = osrfConfigGetValue( NULL, "/logtag" );
/* if we're a source-client, tell the logger */
char* isclient = osrfConfigGetValue(NULL, "/client");
@@ -394,6 +395,7 @@ int osrfSystemBootstrapClientResc( const char* config_file,
if(log_level) llevel = atoi(log_level);
if(!strcmp(log_file, "syslog")) {
+ if(logtag) osrfLogSetLogTag(strdup(logtag));
osrfLogInit( OSRF_LOG_TYPE_SYSLOG, contextnode, llevel );
osrfLogSetSyslogFacility(osrfLogFacilityToInt(facility));
if(actlog) osrfLogSetSyslogActFacility(osrfLogFacilityToInt(actlog));
@@ -444,6 +446,7 @@ int osrfSystemBootstrapClientResc( const char* config_file,
free(unixpath);
free(facility);
free(actlog);
+ free(logtag);
return 0;
}
diff --git a/src/perl/lib/OpenSRF/Utils/Logger.pm b/src/perl/lib/OpenSRF/Utils/Logger.pm
index f97d557..77c8593 100644
--- a/src/perl/lib/OpenSRF/Utils/Logger.pm
+++ b/src/perl/lib/OpenSRF/Utils/Logger.pm
@@ -35,6 +35,7 @@ my $facility; # syslog facility
my $actfac; # activity log syslog facility
my $actfile; # activity log file
my $service = $0; # default service name
+my $service_tag = ''; # default service name
my $syslog_enabled = 0; # is syslog enabled?
my $act_syslog_enabled = 0; # is syslog enabled?
my $logfile_enabled = 1; # are we logging to a file?
@@ -74,6 +75,8 @@ sub set_config {
$max_log_msg_len = $config->bootstrap->loglength;
}
+ $service_tag = $config->bootstrap->logtag;
+
$logfile = $config->bootstrap->logfile;
if($logfile =~ /^syslog/) {
$syslog_enabled = 1;
@@ -159,6 +162,7 @@ sub is_act_filelog {
sub set_service {
my( $self, $svc ) = @_;
$service = $svc;
+ $service .= '/' . $service_tag if (defined $service_tag);
if( is_syslog() ) {
closelog();
openlog($service, 0, $facility);
-----------------------------------------------------------------------
Summary of changes:
examples/opensrf_core.xml.example | 12 ++++++++++++
include/opensrf/log.h | 2 ++
src/libopensrf/log.c | 29 +++++++++++++++++++++++++++--
src/libopensrf/osrf_system.c | 3 +++
src/perl/lib/OpenSRF/Utils/Logger.pm | 9 ++++++++-
src/router/osrf_router_main.c | 2 ++
6 files changed, 54 insertions(+), 3 deletions(-)
hooks/post-receive
--
OpenSRF
More information about the opensrf-commits
mailing list