Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 May 2001 22:19:29 +0200 (CEST)
From:      tobez@tobez.org
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/27412: New port: devel/p5-Log-Dispatch (A suite of OO modules for logging messages to multiple outputs)
Message-ID:  <20010517201929.575BE540B@heechee.tobez.org>

next in thread | raw e-mail | index | archive | help

>Number:         27412
>Category:       ports
>Synopsis:       New port: devel/p5-Log-Dispatch (A suite of OO modules for logging messages to multiple outputs)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 17 13:20:03 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Anton Berezin
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
>Description:

Log::Dispatch is a suite of OO modules for logging messages to multiple
outputs, each of which can have a minimum and maximum log level.  It is
designed to be easily subclassed, both for creating a new dispatcher
object and particularly for creating new outputs.

It also allows both global (dispatcher level) and local (logging object)
message formatting callbacks which allows greater flexibility and should
reduce the need for subclassing.

Subclassing is only needed to send a message to a different output, not
to change the message format.

>How-To-Repeat:
>Fix:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	p5-Log-Dispatch
#	p5-Log-Dispatch/scripts
#	p5-Log-Dispatch/scripts/configure.pl
#	p5-Log-Dispatch/files
#	p5-Log-Dispatch/files/patch-broken-perl-syslog
#	p5-Log-Dispatch/files/patch-simpler-Makefile.PL
#	p5-Log-Dispatch/pkg-plist
#	p5-Log-Dispatch/pkg-descr
#	p5-Log-Dispatch/pkg-comment
#	p5-Log-Dispatch/Makefile
#	p5-Log-Dispatch/distinfo
#
echo c - p5-Log-Dispatch
mkdir -p p5-Log-Dispatch > /dev/null 2>&1
echo c - p5-Log-Dispatch/scripts
mkdir -p p5-Log-Dispatch/scripts > /dev/null 2>&1
echo x - p5-Log-Dispatch/scripts/configure.pl
sed 's/^X//' >p5-Log-Dispatch/scripts/configure.pl << 'END-of-p5-Log-Dispatch/scripts/configure.pl'
X#! /usr/bin/perl -w
Xuse strict;
X
Xunless (defined $ENV{WRKDIRPREFIX} and
X	defined $ENV{REALCURDIR} and
X	defined $ENV{LOCALBASE})
X{
X   die "this script should not be run like that!\n";
X}
X
Xmy $batch = $ENV{BATCH} || 0;
X
Xmy $makedir = "$ENV{WRKDIRPREFIX}$ENV{REALCURDIR}";
Xmy $makefile = "$makedir/Makefile.inc";
Xexit if -f $makefile;
X
Xmy @modules = (
X  {
X     module => 'ApacheLog',
X     check  => 'Apache::Log',
X#     file   => '${PERL_ARCH}/Apache/Log.pm',
X     port   => 'www/mod_perl',
X#     man3   => 'Log::Dispatch::ApacheLog',
X  },
X  {
X     module => 'Email::MIMELite',
X     check  => 'MIME::Lite',
X     port   => 'mail/p5-MIME-Lite',
X  },
X  {
X     module => 'Email::MailSend',
X     check  => 'Mail::Send',
X     port   => 'mail/p5-Mail-Tools',
X  },
X  {
X     module => 'Email::MailSendmail',
X     check  => 'Mail::Sendmail',
X     port   => 'mail/p5-Mail-Sendmail',
X  },
X  {
X     module => 'Syslog',
X     check  => 'Sys::Syslog',
X     port   => 'base perl',
X     nodepend=> 1,
X  }
X);
X
Xscan_modules(@modules);
X@modules = select_modules(@modules);
Xgenerate_makefile_inc(@modules);
Xexit;
X
Xsub generate_makefile_inc
X{
X   my @modules = @_;
X
X   mkdir $makedir, 0777;
X   open INC, "> $makefile" or die "open: $makefile: $!\n";
X
X   for my $m (@modules) {
X      next if $m->{nodepend};
X      my $mpath = $m->{found} || "/nonexistent";
X      $mpath = varify_hardcoded_paths($mpath);
X      my $port = $m->{port};
X      print INC "BUILD_DEPENDS+=	$mpath:\${PORTSDIR}/$port\n";
X   }
X   close INC;
X}
X
Xsub varify_hardcoded_paths
X{
X   local ($_) = @_;
X   s|(perl5/site_perl/)([\d._]+)/|$1\${PERL_VER}/|;
X   s|(perl5/site_perl/\${PERL_VER}/)mach/|$1\${PERL_ARCH}/|;
X   s|^$ENV{LOCALBASE}/|\${LOCALBASE}/|;
X   $_;
X}
X
Xsub got_module
X{
X   my ($m) = @_;
X
X   $m =~ s|::|/|g;
X   $m .= ".pm";
X   for (@INC) {
X      my $f = "$_/$m";
X      return $f if -r $f;
X   }
X   return 0;
X}
X
Xsub scan_modules
X{
X   my @modules = @_;
X   for my $module (@modules) {
X      $module->{found} = got_module($module->{check});
X   }
X}
X
Xsub select_modules
X{
X   my @modules = @_;
X   my @selected;
X   if ($batch) {
X      @selected = batch_select(@_);
X   } else {
X      @selected = ask_user(@_);
X   }
X   my @mod;
X   my %modules = map { $_->{module} => $_ } @modules;
X   for my $module (@selected) {
X      push @mod, $modules{$module} if exists $modules{$module};
X   }
X   @mod;
X}
X
Xsub batch_select
X{
X   my @modules = @_;
X   my @selected;
X   for my $module (@modules) {
X      push @selected, $module->{module} if $module->{found};
X   }
X   @selected;
X}
X
Xsub ask_user
X{
X   my @modules = @_;
X   my @dlg;
X   push @dlg, "/usr/bin/dialog";
X   push @dlg, "--title", "Log::Dispatch configuration";
X   push @dlg, "--clear", "--checklist", <<EOF;
XLog::Dispatch distribution provides several predefined output objects.
XSelect output objects you will likely need.  Those output objects for
Xwhich no extra software packages need to be installed are preselected.
X
X  Please choose options by pressing SPACE to TOGGLE on option ON/OFF
XEOF
X   push @dlg, -1, -1, 9;
X   for my $module (@modules) {
X      push @dlg, $module->{module}, "requires $module->{check}" .
X	 ($module->{found} ? " (already installed)" : ""),
X         ($module->{found} ? "ON" : "OFF");
X   }
X
X   my @selected;
X
X   my $pid = open(RESULT, "-|");
X   if ($pid) {
X      # parent
X      my $r = "";
X      while (<RESULT>) {
X	 $r .= $_;
X      }
X      close(RESULT) or die "dialog(1) exited with non-zero return code\n";
X      $r =~ s/"//g;
X      $r =~ s/\s+/ /g;
X      @selected = split ' ', $r;
X   } elsif (defined $pid) {
X      # child
X      open XCHG, ">& STDOUT" or die "dup: $!\n";
X      open STDOUT, ">& STDERR" or die "dup: $!\n";
X      open STDERR, ">& XCHG" or die "dup: $!\n";
X      close XCHG if fileno(XCHG) > 2;
X      exec @dlg or die "cannot exec: $!\n";
X   } else {
X      die "cannot fork: $!\n";
X   }
X
X   return @selected;
X}
END-of-p5-Log-Dispatch/scripts/configure.pl
echo c - p5-Log-Dispatch/files
mkdir -p p5-Log-Dispatch/files > /dev/null 2>&1
echo x - p5-Log-Dispatch/files/patch-broken-perl-syslog
sed 's/^X//' >p5-Log-Dispatch/files/patch-broken-perl-syslog << 'END-of-p5-Log-Dispatch/files/patch-broken-perl-syslog'
X--- Dispatch/Syslog.pm.orig	Thu May 17 16:23:51 2001
X+++ Dispatch/Syslog.pm	Thu May 17 16:24:15 2001
X@@ -45,7 +45,7 @@
X     $self->{ident}    = $params{ident} || $0;
X     $self->{logopt}   = $params{logopt} || '';
X     $self->{facility} = $params{facility} || 'user';
X-    $self->{socket}   = $params{socket} || 'unix';
X+    $self->{socket}   = $params{socket} || undef;
X 
X     $self->{priorities} = [ 'DEBUG',
X 			    'INFO',
X@@ -56,7 +56,7 @@
X 			    'ALERT',
X 			    'EMERG' ];
X 
X-    Sys::Syslog::setlogsock $self->{socket};
X+    Sys::Syslog::setlogsock $self->{socket} if defined $self->{socket};
X }
X 
X sub log_message
END-of-p5-Log-Dispatch/files/patch-broken-perl-syslog
echo x - p5-Log-Dispatch/files/patch-simpler-Makefile.PL
sed 's/^X//' >p5-Log-Dispatch/files/patch-simpler-Makefile.PL << 'END-of-p5-Log-Dispatch/files/patch-simpler-Makefile.PL'
X--- Makefile.PL.orig	Thu May 17 18:13:04 2001
X+++ Makefile.PL	Thu May 17 18:13:22 2001
X@@ -6,104 +6,8 @@
X     require 5.005;
X }
X 
X-{
X-    unless (-d './Install')
X-    {
X-	mkdir './Install', 0755
X-	    or die "can't make dir ./Install: $!";
X-    }
X-
X-    my %config;
X-    $config{email_address} = prompt( q[
X-To do a full test of the Log::Dispatch::* modules, we need
X-to attempt to send an email.  If you want these tests to
X-be done please supply an address.
X-Address?] );
X-
X-    $config{syslog} = prompt( q[ 
X-Do you want to test Log::Dispatch::Syslog by sending a message as
X-daemon.notice?
X-Yes/No?], 'No' );
X-
X-    delete $config{syslog} if $config{syslog} !~ /^y(?:es)?/i;
X-
X-    if ($config{syslog})
X-    {
X-	my $default;
X-	foreach ( qw( /var/adm/messages
X-                      /var/adm/syslog
X-                      /var/log/messages
X-                      /var/log/syslog
X-		      /var/log/syslog
X-		      /etc/log/syslog ) )
X-	{
X-	    if (-e)
X-	    {
X-		$default = $_;
X-		last;
X-	    }
X-	}
X-
X-	$config{syslog_file} = prompt('What file would a message sent as daemon.notice end up in?', $default);
X-
X-	unless (-r $config{syslog_file})
X-	{
X-	    warn "$config{syslog_file} is not readable.  Syslog tests will be skipped\n";
X-	    delete $config{syslog};
X-	    delete $config{syslog_file};
X-	}
X-    }
X-
X-    open CFG, ">./Install/TestConfig.pm"
X-	or die "can't write to ./Install/TestConfig.pm: $!";
X-
X-    print CFG <<"EOF";
X-#
X-#    This file was automatically generated by Makefile.PL. Do not
X-#    edit, instead do a "make realclean" in the toplevel directory and
X-#    rerun "perl makefile.PL".
X-#
X-
X-package Install::TestConfig;
X-EOF
X-
X-    print CFG "\%config = \n(\n";
X-    foreach (keys %config)
X-    {
X-	print CFG "\t$_ => '$config{$_}',\n";
X-    }
X-    print CFG ');';
X-    close CFG;
X-}
X 
X my %extra_pms;
X-{
X-    print <<'EOF';
X-
X-Please list any extra modules you would like added as part of this
X-installation.  These should be located somewhere under the Dispatch/
X-directory.  Please type the path after Dispatch/ (including the .pm
X-extension).
X-
X-Press enter a blank line when you are done.
X-
X-EOF
X-
X-    while (1)
X-    {
X-	chomp (my $module = <STDIN>);
X-	last unless $module;
X-
X-	if (-e "./Dispatch/$module")
X-	{
X-	    $extra_pms{"Dispatch/$module"} = '$(INST_LIBDIR)/Dispatch/' . $module;
X-	}
X-	else
X-	{
X-	    warn "Couldn't find ./Dispatch/$module\n";
X-	}
X-    }
X-}
X 
X 
X 
END-of-p5-Log-Dispatch/files/patch-simpler-Makefile.PL
echo x - p5-Log-Dispatch/pkg-plist
sed 's/^X//' >p5-Log-Dispatch/pkg-plist << 'END-of-p5-Log-Dispatch/pkg-plist'
Xlib/perl5/site_perl/%%PERL_VER%%/%%PERL_ARCH%%/auto/Log/Dispatch/.packlist
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/ApacheLog.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Base.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Email.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Email/MIMELite.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Email/MailSend.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Email/MailSendmail.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/File.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Handle.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Output.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Screen.pm
Xlib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Syslog.pm
X@dirrm lib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch/Email
X@unexec rmdir %D/lib/perl5/site_perl/%%PERL_VER%%/%%PERL_ARCH%%/auto/Log/Dispatch 2>/dev/null || true
X@unexec rmdir %D/lib/perl5/site_perl/%%PERL_VER%%/%%PERL_ARCH%%/auto/Log 2>/dev/null || true
X@unexec rmdir %D/lib/perl5/site_perl/%%PERL_VER%%/Log/Dispatch 2>/dev/null || true
X@unexec rmdir %D/lib/perl5/site_perl/%%PERL_VER%%/Log 2>/dev/null || true
END-of-p5-Log-Dispatch/pkg-plist
echo x - p5-Log-Dispatch/pkg-descr
sed 's/^X//' >p5-Log-Dispatch/pkg-descr << 'END-of-p5-Log-Dispatch/pkg-descr'
XLog::Dispatch is a suite of OO modules for logging messages to multiple
Xoutputs, each of which can have a minimum and maximum log level.  It is
Xdesigned to be easily subclassed, both for creating a new dispatcher
Xobject and particularly for creating new outputs.
X
XIt also allows both global (dispatcher level) and local (logging object)
Xmessage formatting callbacks which allows greater flexibility and should
Xreduce the need for subclassing.
X
XSubclassing is only needed to send a message to a different output, not
Xto change the message format.
X
X-Anton
X<tobez@tobez.org>
END-of-p5-Log-Dispatch/pkg-descr
echo x - p5-Log-Dispatch/pkg-comment
sed 's/^X//' >p5-Log-Dispatch/pkg-comment << 'END-of-p5-Log-Dispatch/pkg-comment'
XA suite of OO modules for logging messages to multiple outputs
END-of-p5-Log-Dispatch/pkg-comment
echo x - p5-Log-Dispatch/Makefile
sed 's/^X//' >p5-Log-Dispatch/Makefile << 'END-of-p5-Log-Dispatch/Makefile'
X# New ports collection makefile for:	devel/p5-Log-Dispatch
X# Date created:				17 May 2001
X# Whom:					Anton Berezin <tobez@tobez.org>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	Log-Dispatch
XPORTVERSION=	1.79
XCATEGORIES=	devel perl5
XMASTER_SITES=	${MASTER_SITE_PERL_CPAN}
XMASTER_SITE_SUBDIR=	Log
XPKGNAMEPREFIX=	p5-
X
XMAINTAINER=	tobez@tobez.org
X
XRUN_DEPENDS=    ${BUILD_DEPENDS}
X
XPERL_CONFIGURE=	yes
X
XMAN3=	Log::Dispatch.3 \
X	Log::Dispatch::ApacheLog.3 \
X	Log::Dispatch::Base.3 \
X	Log::Dispatch::Email.3 \
X	Log::Dispatch::Email::MIMELite.3 \
X	Log::Dispatch::Email::MailSend.3 \
X	Log::Dispatch::Email::MailSendmail.3 \
X	Log::Dispatch::File.3 \
X	Log::Dispatch::Handle.3 \
X	Log::Dispatch::Output.3 \
X	Log::Dispatch::Screen.3 \
X	Log::Dispatch::Syslog.3
XMANPREFIX=	${PREFIX}/lib/perl5/${PERL_VERSION}
X
XSCRIPTS_ENV+=	WRKDIRPREFIX="${WRKDIRPREFIX}" \
X		REALCURDIR="${.CURDIR}"
X
Xpre-fetch:
X	@${SETENV} ${SCRIPTS_ENV} ${PERL} ${SCRIPTDIR}/configure.pl
X
Xpost-clean:
X	@${RM} -f ${WRKDIRPREFIX}${.CURDIR}/Makefile.inc
X
X.if exists(${WRKDIRPREFIX}${.CURDIR}/Makefile.inc)
X.include "${WRKDIRPREFIX}${.CURDIR}/Makefile.inc"
X.endif
X
X.include <bsd.port.mk>
END-of-p5-Log-Dispatch/Makefile
echo x - p5-Log-Dispatch/distinfo
sed 's/^X//' >p5-Log-Dispatch/distinfo << 'END-of-p5-Log-Dispatch/distinfo'
XMD5 (Log-Dispatch-1.79.tar.gz) = 454da144672bd6b0fb24a12b17830991
END-of-p5-Log-Dispatch/distinfo
exit

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010517201929.575BE540B>