[OpenSRF-GIT] OpenSRF branch master updated. 77d42eea11a3551331e6cecd409f575ae584548d

Evergreen Git git at git.evergreen-ils.org
Wed Feb 6 17:04:13 EST 2013


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  77d42eea11a3551331e6cecd409f575ae584548d (commit)
       via  7667d34b4913b57740695a912a69f4d520fbcb9f (commit)
      from  f086d4c0aaaa605139aa18658a62fa919294cdc8 (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 77d42eea11a3551331e6cecd409f575ae584548d
Author: Bill Erickson <berick at esilibrary.com>
Date:   Wed Oct 17 14:37:01 2012 -0400

    Logger.pm whitespace cleanup
    
    Apply 4-space "tabs" consistently.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/src/perl/lib/OpenSRF/Utils/Logger.pm b/src/perl/lib/OpenSRF/Utils/Logger.pm
index be13ecd..f51f16e 100644
--- a/src/perl/lib/OpenSRF/Utils/Logger.pm
+++ b/src/perl/lib/OpenSRF/Utils/Logger.pm
@@ -1,5 +1,4 @@
 package OpenSRF::Utils::Logger;
-# vim:ts=4:noet:
 use strict;
 use vars qw($AUTOLOAD @EXPORT_OK %EXPORT_TAGS);
 use Exporter;
@@ -29,62 +28,62 @@ push @EXPORT_OK, '$logger';
 
 %EXPORT_TAGS = ( level => [ qw/ NONE ERROR WARN INFO DEBUG INTERNAL / ], logger => [ '$logger' ] );
 
-my $config;							# config handle
-my $loglevel = INFO();				# global log level
-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 $syslog_enabled = 0;			# is syslog enabled?
-my $act_syslog_enabled = 0;	# is syslog enabled?
-my $logfile_enabled = 1;		# are we logging to a file?
-my $act_logfile_enabled = 1;	# are we logging to a file?
-my $max_log_msg_len = 1536;			# SYSLOG default maximum is 2048
+my $config;             # config handle
+my $loglevel = INFO();  # global log level
+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 $syslog_enabled = 0; # is syslog enabled?
+my $act_syslog_enabled = 0; # is syslog enabled?
+my $logfile_enabled = 1;    # are we logging to a file?
+my $act_logfile_enabled = 1;# are we logging to a file?
+my $max_log_msg_len = 1536; # SYSLOG default maximum is 2048
 
 our $logger = "OpenSRF::Utils::Logger";
 
 # log levels
-sub ACTIVITY	{ return -1; }
-sub NONE			{ return 0;	}
-sub ERROR		{ return 1;	}
-sub WARN			{ return 2;	}
-sub INFO			{ return 3;	}
-sub DEBUG		{ return 4;	}
-sub INTERNAL	{ return 5;	}
-sub ALL			{ return 100; }
+sub ACTIVITY { return -1; }
+sub NONE     { return 0; }
+sub ERROR    { return 1; }
+sub WARN     { return 2; }
+sub INFO     { return 3; }
+sub DEBUG    { return 4; }
+sub INTERNAL { return 5; }
+sub ALL      { return 100; }
 
 my $isclient;  # true if we control the osrf_xid
 
 # load up our config options
 sub set_config {
 
-	return if defined $config;
+    return if defined $config;
 
-	$config = OpenSRF::Utils::Config->current;
-	if( !defined($config) ) {
-		$loglevel = INFO();
-		warn "*** Logger found no config.  Using STDERR ***\n";
-		return;
-	}
+    $config = OpenSRF::Utils::Config->current;
+    if( !defined($config) ) {
+        $loglevel = INFO();
+        warn "*** Logger found no config.  Using STDERR ***\n";
+        return;
+    }
 
-	$loglevel =  $config->bootstrap->loglevel; 
+    $loglevel =  $config->bootstrap->loglevel; 
 
-	if ($config->bootstrap->loglength) {
-		$max_log_msg_len = $config->bootstrap->loglength;
-	}
+    if ($config->bootstrap->loglength) {
+        $max_log_msg_len = $config->bootstrap->loglength;
+    }
 
-	$logfile = $config->bootstrap->logfile;
-	if($logfile =~ /^syslog/) {
-		$syslog_enabled = 1;
-		$logfile_enabled = 0;
+    $logfile = $config->bootstrap->logfile;
+    if($logfile =~ /^syslog/) {
+        $syslog_enabled = 1;
+        $logfile_enabled = 0;
         $logfile = $config->bootstrap->syslog;
-		$facility = $logfile;
-		$logfile = undef;
-		$facility = _fac_to_const($facility);
-		openlog($service, 0, $facility);
+        $facility = $logfile;
+        $logfile = undef;
+        $facility = _fac_to_const($facility);
+        openlog($service, 0, $facility);
 
-	} else { $logfile = "$logfile"; }
+    } else { $logfile = "$logfile"; }
 
 
     if($syslog_enabled) {
@@ -103,108 +102,108 @@ sub set_config {
         # we're not syslogging, use any specified activity log file.
         # Fall back to the standard log file otherwise
         # --------------------------------------------------------------
-		$act_syslog_enabled = 0;
-		$act_logfile_enabled = 1;
+        $act_syslog_enabled = 0;
+        $act_logfile_enabled = 1;
         $actfile = $config->bootstrap->actlog || $config->bootstrap->logfile;
     }
 
-	my $client = OpenSRF::Utils::Config->current->bootstrap->client();
+    my $client = OpenSRF::Utils::Config->current->bootstrap->client();
 
-	if ($ENV{OSRF_LOG_CLIENT} or $ENV{MOD_PERL}) {
-		$isclient = 1;
-		return;
-	}
+    if ($ENV{OSRF_LOG_CLIENT} or $ENV{MOD_PERL}) {
+        $isclient = 1;
+        return;
+    }
 
-	if (!$client) {
-		$isclient = 0;
-		return;
-	}
-	$isclient = ($client =~ /^true$/iog) ?  1 : 0;
+    if (!$client) {
+        $isclient = 0;
+        return;
+    }
+    $isclient = ($client =~ /^true$/iog) ?  1 : 0;
 }
 
 sub _fac_to_const {
-	my $name = shift;
-	return LOG_LOCAL0 unless $name;
-	return LOG_LOCAL0 if $name =~ /local0/i;
-	return LOG_LOCAL1 if $name =~ /local1/i;
-	return LOG_LOCAL2 if $name =~ /local2/i;
-	return LOG_LOCAL3 if $name =~ /local3/i;
-	return LOG_LOCAL4 if $name =~ /local4/i;
-	return LOG_LOCAL5 if $name =~ /local5/i;
-	return LOG_LOCAL6 if $name =~ /local6/i;
-	return LOG_LOCAL7 if $name =~ /local7/i;
-	return LOG_LOCAL0;
+    my $name = shift;
+    return LOG_LOCAL0 unless $name;
+    return LOG_LOCAL0 if $name =~ /local0/i;
+    return LOG_LOCAL1 if $name =~ /local1/i;
+    return LOG_LOCAL2 if $name =~ /local2/i;
+    return LOG_LOCAL3 if $name =~ /local3/i;
+    return LOG_LOCAL4 if $name =~ /local4/i;
+    return LOG_LOCAL5 if $name =~ /local5/i;
+    return LOG_LOCAL6 if $name =~ /local6/i;
+    return LOG_LOCAL7 if $name =~ /local7/i;
+    return LOG_LOCAL0;
 }
 
 sub is_syslog {
-	set_config();
-	return $syslog_enabled;
+    set_config();
+    return $syslog_enabled;
 }
 
 sub is_act_syslog {
-	set_config();
-	return $act_syslog_enabled;
+    set_config();
+    return $act_syslog_enabled;
 }
 
 sub is_filelog {
-	set_config();
-	return $logfile_enabled;
+    set_config();
+    return $logfile_enabled;
 }
 
 sub is_act_filelog {
-	set_config();
-	return $act_logfile_enabled;
+    set_config();
+    return $act_logfile_enabled;
 }
 
 sub set_service {
-	my( $self, $svc ) = @_;
-	$service = $svc;	
-	if( is_syslog() ) {
-		closelog();
-		openlog($service, 0, $facility);
-	}
+    my( $self, $svc ) = @_;
+    $service = $svc;    
+    if( is_syslog() ) {
+        closelog();
+        openlog($service, 0, $facility);
+    }
 }
 
 sub error {
-	my( $self, $msg, $level ) = @_;
-	$level = ERROR() unless defined ($level);
-	_log_message( $msg, $level );
+    my( $self, $msg, $level ) = @_;
+    $level = ERROR() unless defined ($level);
+    _log_message( $msg, $level );
 }
 
 sub warn {
-	my( $self, $msg, $level ) = @_;
-	$level = WARN() unless defined ($level);
-	_log_message( $msg, $level );
+    my( $self, $msg, $level ) = @_;
+    $level = WARN() unless defined ($level);
+    _log_message( $msg, $level );
 }
 
 sub info {
-	my( $self, $msg, $level ) = @_;
-	$level = INFO() unless defined ($level);
-	_log_message( $msg, $level );
+    my( $self, $msg, $level ) = @_;
+    $level = INFO() unless defined ($level);
+    _log_message( $msg, $level );
 }
 
 sub debug {
-	my( $self, $msg, $level ) = @_;
-	$level = DEBUG() unless defined ($level);
-	_log_message( $msg, $level );
+    my( $self, $msg, $level ) = @_;
+    $level = DEBUG() unless defined ($level);
+    _log_message( $msg, $level );
 }
 
 sub internal {
-	my( $self, $msg, $level ) = @_;
-	$level = INTERNAL() unless defined ($level);
-	_log_message( $msg, $level );
+    my( $self, $msg, $level ) = @_;
+    $level = INTERNAL() unless defined ($level);
+    _log_message( $msg, $level );
 }
 
 sub activity {
-	my( $self, $msg ) = @_;
-	_log_message( $msg, ACTIVITY() );
+    my( $self, $msg ) = @_;
+    _log_message( $msg, ACTIVITY() );
 }
 
 # for backward compability
 sub transport {
-	my( $self, $msg, $level ) = @_;
-	$level = DEBUG() unless defined ($level);
-	_log_message( $msg, $level );
+    my( $self, $msg, $level ) = @_;
+    $level = DEBUG() unless defined ($level);
+    _log_message( $msg, $level );
 }
 
 
@@ -229,47 +228,47 @@ sub get_osrf_xid { return $osrf_xid; }
 
    
 sub _log_message {
-	my( $msg, $level ) = @_;
-	return if $level > $loglevel;
+    my( $msg, $level ) = @_;
+    return if $level > $loglevel;
 
-	my $l; my $n; 
-	my $fac = $facility;
+    my $l; my $n; 
+    my $fac = $facility;
 
-	if ($level == ERROR())			{$l = LOG_ERR; $n = "ERR "; }
-	elsif ($level == WARN())		{$l = LOG_WARNING; $n = "WARN"; }
-	elsif ($level == INFO())		{$l = LOG_INFO; $n = "INFO"; }	
-	elsif ($level == DEBUG())		{$l = LOG_DEBUG; $n = "DEBG"; }
-	elsif ($level == INTERNAL())	{$l = LOG_DEBUG; $n = "INTL"; }
-	elsif ($level == ACTIVITY())	{$l = LOG_INFO; $n = "ACT"; $fac = $actfac; }
+    if ($level == ERROR())            {$l = LOG_ERR; $n = "ERR "; }
+    elsif ($level == WARN())        {$l = LOG_WARNING; $n = "WARN"; }
+    elsif ($level == INFO())        {$l = LOG_INFO; $n = "INFO"; }    
+    elsif ($level == DEBUG())        {$l = LOG_DEBUG; $n = "DEBG"; }
+    elsif ($level == INTERNAL())    {$l = LOG_DEBUG; $n = "INTL"; }
+    elsif ($level == ACTIVITY())    {$l = LOG_INFO; $n = "ACT"; $fac = $actfac; }
 
-	my( undef, $file, $line_no ) = caller(1);
+    my( undef, $file, $line_no ) = caller(1);
    $file =~ s#/.*/##og;
 
-	# help syslog with the formatting
-	$msg =~ s/\%/\%\%/gso if( is_act_syslog() or is_syslog() );
+    # help syslog with the formatting
+    $msg =~ s/\%/\%\%/gso if( is_act_syslog() or is_syslog() );
 
-	$msg = "[$n:"."$$".":$file:$line_no:$osrf_xid] $msg";
+    $msg = "[$n:"."$$".":$file:$line_no:$osrf_xid] $msg";
 
-	# Trim the message to the configured maximum log message length
-	$msg = substr($msg, 0, $max_log_msg_len); 
+    # Trim the message to the configured maximum log message length
+    $msg = substr($msg, 0, $max_log_msg_len); 
 
-	if( $level == ACTIVITY() ) {
-		if( is_act_syslog() ) { syslog( $fac | $l, $msg ); } 
-		elsif( is_act_filelog() ) { _write_file( $msg, 1 ); }
+    if( $level == ACTIVITY() ) {
+        if( is_act_syslog() ) { syslog( $fac | $l, $msg ); } 
+        elsif( is_act_filelog() ) { _write_file( $msg, 1 ); }
 
-	} else {
-		if( is_syslog() ) { syslog( $fac | $l, $msg ); }
-		elsif( is_filelog() ) { _write_file($msg); }
-	}
+    } else {
+        if( is_syslog() ) { syslog( $fac | $l, $msg ); }
+        elsif( is_filelog() ) { _write_file($msg); }
+    }
 
-	return $msg;
+    return $msg;
 }
 
 sub _write_file {
-	my ($msg, $isact) = @_;
-	my $file = $isact ? $actfile : $logfile;
-	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);  
-	$year += 1900; $mon += 1;
+    my ($msg, $isact) = @_;
+    my $file = $isact ? $actfile : $logfile;
+    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);  
+    $year += 1900; $mon += 1;
 
     if ($file) {
         sysopen( SINK, $file, O_NONBLOCK|O_WRONLY|O_APPEND|O_CREAT ) 
@@ -277,9 +276,9 @@ sub _write_file {
     } else {
         open (SINK, ">&2");  # print to STDERR as warned
     }
-	binmode(SINK, ':utf8');
-	printf SINK "[%04d-%02d-%02d %02d:%02d:%02d] %s %s\n", $year, $mon, $mday, $hour, $min, $sec, $service, $msg;
-	close( SINK );
+    binmode(SINK, ':utf8');
+    printf SINK "[%04d-%02d-%02d %02d:%02d:%02d] %s %s\n", $year, $mon, $mday, $hour, $min, $sec, $service, $msg;
+    close( SINK );
 }
 
 1;

commit 7667d34b4913b57740695a912a69f4d520fbcb9f
Author: Bill Erickson <berick at esilibrary.com>
Date:   Wed Oct 17 14:31:02 2012 -0400

    Enable client logtrace with environment vars
    
    Supports a new environment variable OSRF_LOG_CLIENT which, if true,
    enables control and generation of the client log trace value.  This is
    the same as setting <client>true</client> within the opensrf core
    configuration file.
    
    As a shortcut, if the MOD_PERL environment variable is set, assume
    client=true.
    
    This allows clients and non-clients to share an opensrf core
    configuration file, when previously the only difference between the two
    was the <client> setting.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/src/perl/lib/OpenSRF/Utils/Logger.pm b/src/perl/lib/OpenSRF/Utils/Logger.pm
index 2a450ae..be13ecd 100644
--- a/src/perl/lib/OpenSRF/Utils/Logger.pm
+++ b/src/perl/lib/OpenSRF/Utils/Logger.pm
@@ -109,6 +109,12 @@ sub set_config {
     }
 
 	my $client = OpenSRF::Utils::Config->current->bootstrap->client();
+
+	if ($ENV{OSRF_LOG_CLIENT} or $ENV{MOD_PERL}) {
+		$isclient = 1;
+		return;
+	}
+
 	if (!$client) {
 		$isclient = 0;
 		return;

-----------------------------------------------------------------------

Summary of changes:
 src/perl/lib/OpenSRF/Utils/Logger.pm |  255 +++++++++++++++++-----------------
 1 files changed, 130 insertions(+), 125 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list