perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@hyperreal.org
Subject cvs commit: modperl/t/net/perl log.pl
Date Sun, 12 Jul 1998 21:21:39 GMT
dougm       98/07/12 14:21:39

  Modified:    .        .cvsignore Changes MANIFEST Makefile.PL ToDo
  Added:       Log      Log.pm Makefile.PL
               src/modules/perl Log.xs
               t/modules log.t
               t/net/perl log.pl
  Log:
  added Apache::Log module
  
  Revision  Changes    Path
  1.6       +3 -1      modperl/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /export/home/cvs/modperl/.cvsignore,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- .cvsignore	1998/06/09 16:53:08	1.5
  +++ .cvsignore	1998/07/12 21:21:33	1.6
  @@ -27,4 +27,6 @@
   t/httpd_conf
   t/perlsections.pl   
   t/conf/LoadModule.conf
  -t/docs/hooks.txt
  \ No newline at end of file
  +t/docs/hooks.txt
  +Log/Makefile
  +Log/pm_to_blib
  
  
  
  1.68      +2 -0      modperl/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /export/home/cvs/modperl/Changes,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- Changes	1998/07/12 20:19:40	1.67
  +++ Changes	1998/07/12 21:21:34	1.68
  @@ -8,6 +8,8 @@
   
   =item 1.12_01-dev
   
  +added Apache::Log module (enable with PERL_LOG_API=1 or EVERYTHING=1)
  +
   add mod_perl_version.pm so CPAN.pm can 'install mod_perl' again
   
   ensure Apache::Server::CWD is untainted
  
  
  
  1.23      +5 -0      modperl/MANIFEST
  
  Index: MANIFEST
  ===================================================================
  RCS file: /export/home/cvs/modperl/MANIFEST,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- MANIFEST	1998/07/12 20:19:40	1.22
  +++ MANIFEST	1998/07/12 21:21:34	1.23
  @@ -3,6 +3,8 @@
   Constants/Makefile.PL
   ModuleConfig/ModuleConfig.pm
   ModuleConfig/Makefile.PL
  +Log/Makefile.PL
  +Log/Log.pm
   CREDITS
   INSTALL
   INSTALL.apaci
  @@ -55,6 +57,7 @@
   src/modules/perl/Constants.xs
   src/modules/perl/Apache.xs
   src/modules/perl/ModuleConfig.xs
  +src/modules/perl/Log.xs
   src/modules/perl/Tie.xs
   src/modules/perl/ldopts
   src/modules/perl/mod_perl.c
  @@ -81,6 +84,7 @@
   t/modules/eperl.t
   t/modules/embperl.t
   t/modules/httpdconf.t
  +t/modules/log.t
   t/modules/psections.t
   t/modules/perlrun.t
   t/modules/include.t
  @@ -104,6 +108,7 @@
   #t/internal/resolver.t
   t/internal/taint.t
   t/internal/tie.t
  +t/net/perl/log.pl
   t/net/perl/file_upload.cgi
   t/net/perl/tie_table.pl
   t/net/perl/qredirect.pl
  
  
  
  1.57      +26 -14    modperl/Makefile.PL
  
  Index: Makefile.PL
  ===================================================================
  RCS file: /export/home/cvs/modperl/Makefile.PL,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- Makefile.PL	1998/07/12 20:19:41	1.56
  +++ Makefile.PL	1998/07/12 21:21:34	1.57
  @@ -143,6 +143,7 @@
   $ADD_MODULE = "";
   $PERL_DIRECTIVE_HANDLERS = 0;
   $PERL_TIE_TABLES = 0;
  +$PERL_LOG_API = 0;
   my %experimental = map { $_,1 } qw{
   PERL_GET_SET_HANDLERS
   PERL_MARK_WHERE
  @@ -182,6 +183,7 @@
      PERL_METHOD_HANDLERS
      PERL_DIRECTIVE_HANDLERS
      PERL_TIE_TABLES
  +   PERL_LOG_API
   };
   
   $callback_alias{PERL_INIT} = "PERL_HEADER_PARSER";
  @@ -258,7 +260,7 @@
   
   if($EVERYTHING) {
       @callback_hooks{qw(PERL_STACKED_HANDLERS PERL_METHOD_HANDLERS)} = (1) x 2;
  -    for(qw(ALL_HOOKS PERL_SSI PERL_SECTIONS PERL_TIE_TABLES PERL_DIRECTIVE_HANDLERS)) {
  +    for(qw(ALL_HOOKS PERL_SSI PERL_SECTIONS PERL_TIE_TABLES PERL_DIRECTIVE_HANDLERS PERL_LOG_API))
{
          $$_ = 1;
       }
   }
  @@ -266,26 +268,16 @@
   
   if($ALL_HOOKS) {
       for (@callback_hooks) {
  -	next if /(Table|Handler)s?$/i;
  +	next if /(Api|Table|Handler)s?$/i;
   	$callback_hooks{$_}++;
       }
   }
   
   if($DYNAMIC) {
  -    $PERL_DIRECTIVE_HANDLERS = $PERL_TIE_TABLES = 1;
  +    $PERL_DIRECTIVE_HANDLERS = $PERL_TIE_TABLES = $PERL_LOG_API = 1;
   }
   
   my @xs_modules = qw(Apache Apache::Constants);
  -if($PERL_DIRECTIVE_HANDLERS) {
  -    push @xs_modules, "Apache::ModuleConfig";
  -    $callback_hooks{PERL_DIRECTIVE_HANDLERS} = 1;
  -}
  -if($PERL_TIE_TABLES) {
  -    push @xs_modules, "Apache::Tie";
  -    $callback_hooks{PERL_TIE_TABLES} = 1;
  -}
  -
  -my @xs_mod_snames = map { (my $s = $_) =~ s/.*:://; $s } @xs_modules;
   
   if($Is_Win32) {
       $NO_HTTPD = 1;
  @@ -355,6 +347,11 @@
   	if(($mmn < MMN_130) and $USE_APACI) { #1.3.0
   	    print "Sorry, need 1.3.0+ for USE_APACI\n";
   	    $USE_APACI = $USE_DSO = 0;
  +	    
  +	}
  +	if(($mmn < MMN_130) and $PERL_LOG_API) { #1.3.0
  +	    $PERL_LOG_API = 0;
  +	    $cant_hook{PERL_LOG_API} = "(need 1.3.0 or higher)";
   	}
   	unless ($DO_HTTPD or $NO_HTTPD) {
   	    $ans = _prompt("Shall I build httpd in $adir for you?", "y");
  @@ -485,6 +482,21 @@
       last if $APACHE_SRC;
   }
   
  +if($PERL_DIRECTIVE_HANDLERS) {
  +    push @xs_modules, "Apache::ModuleConfig";
  +    $callback_hooks{PERL_DIRECTIVE_HANDLERS} = 1;
  +}
  +if($PERL_TIE_TABLES) {
  +    push @xs_modules, "Apache::Tie";
  +    $callback_hooks{PERL_TIE_TABLES} = 1;
  +}
  +if($PERL_LOG_API) {
  +    push @xs_modules, "Apache::Log";
  +    $callback_hooks{PERL_LOG_API} = 1;
  +}
  +
  +my @xs_mod_snames = map { (my $s = $_) =~ s/.*:://; $s } @xs_modules;
  +
   if($DYNAMIC) {
       for (@xs_mod_snames) {
   	cp "src/modules/perl/${_}.xs", "${_}/${_}.xs" if $DYNAMIC;
  @@ -545,7 +557,7 @@
   	$why = ($cant_hook{$k} || "(enable with $k=1)") unless $v;
   	$k =~ s/([A-Z]+)/ucfirst(lc($1))/ge;
   	$k =~ s/_//g;
  -	$k .= "Handler" unless $k =~ /(Table|Handler)s?$/;
  +	$k .= "Handler" unless $k =~ /(Api|Table|Handler)s?$/;
   	push @mod_perl_hooks, $k;
   	print $k . '.' x (28 - length($k));
   	print $v ? "enabled\n" : "disabled $why\n";
  
  
  
  1.40      +0 -3      modperl/ToDo
  
  Index: ToDo
  ===================================================================
  RCS file: /export/home/cvs/modperl/ToDo,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- ToDo	1998/07/12 19:54:13	1.39
  +++ ToDo	1998/07/12 21:21:35	1.40
  @@ -38,7 +38,6 @@
     + DONE
     + SUID access http://www.courtesan.com/sudo/
     + $ENV{PATH}/PerlSetEnv and PerlTaintCheck
  -  + IO.so and -Xlinker -E "Salvador Fandiņo" <fandino@usa.net>
   
   - PerlRun::handler in cgi_to_mod_perl.pod
   
  @@ -237,8 +236,6 @@
   ---------------------------------------------------------------------------
   NEW MODULE STUFF
   ---------------------------------------------------------------------------
  -
  -- integrate Apache::Log
   
   - should Apache::Registry use filename instead of vhost_name+uri?
                 Ben Laurie <ben@algroup.co.uk>
  
  
  
  1.1                  modperl/Log/Log.pm
  
  Index: Log.pm
  ===================================================================
  package Apache::Log;
  
  use strict;
  use Apache ();
  use vars qw($VERSION @ISA);
  
  use DynaLoader ();
  @ISA = qw(DynaLoader Apache Apache::Server);
  
  $VERSION = '1.00';
  
  *Apache::log = *Apache::Server::log = \&log;
  
  sub log { 
      my $self = shift;
      my $s;
      if(ref $self) { 
  	if($self->isa("Apache")) {
  	    $s = $self->server;
  	}
  	elsif($self->isa("Apache::Server")) {
  	    $s = $self;
  	}
  	else {
  	    die("Can't pull an Apache::Server from $self");
  	}
      }
      else {
  	$s = Apache->request->server;
      }
      bless $s; 
  }
  
  if($ENV{MOD_PERL}) {
      bootstrap Apache::Log $VERSION;
  }
  
  1;
  __END__
  
  =head1 NAME
  
  Apache::Log - Interface to Apache logging
  
  =head1 SYNOPSIS
  
    use Apache::Log ();
    my $log = $r->log;
    $log->debug("You only see this if `LogLevel' is set to `debug'");
  
  =head1 DESCRIPTION
  
  The Apache::Log module provides an interface to Apache's I<ap_log_error>
  routine.
  
  =over 4
  
  =item emergency
  
  =item alert
  
  =item critical
  
  =item error
  
  =item warn
  
  =item notice
  
  =item info
  
  =item debug
  
  =back
  
  =head1 AUTHOR
  
  Doug MacEachern
  
  =head1 SEE ALSO
  
  mod_perl(3), Apache(3).
  
  =cut
  
  
  
  1.1                  modperl/Log/Makefile.PL
  
  Index: Makefile.PL
  ===================================================================
  use ExtUtils::MakeMaker;
  use Config;
  
  $apache_1_3_inc = join ' ', map { 
      join '', ' -I../$(APACHE_SRC)/', $_, ' -I$(APACHE_SRC)/', $_;
  } qw(include main os/unix);
  
  WriteMakefile(
      NAME	=> "Apache::Log",
      VERSION_FROM => "Log.pm",
      INC => '-I../src -I../src/modules/perl -I$(APACHE_SRC) -I../$(APACHE_SRC) '.$apache_1_3_inc,
  );
  
  
  
  
  1.1                  modperl/src/modules/perl/Log.xs
  
  Index: Log.xs
  ===================================================================
  #ifdef MOD_PERL
  #include "mod_perl.h"
  #else
  #include "modules/perl/mod_perl.h"
  #endif
  
  static void ApacheLog(int level, const server_rec *s, SV *msg)
  {
      char *file = NULL;
      int line   = 0;
      if(level == APLOG_DEBUG) {
  	SV *caller = perl_eval_pv("[ (caller)[1,2] ]", TRUE);
  	file = SvPV(*av_fetch((AV *)SvRV(caller), 0, FALSE),na);
  	line = (int)SvIV(*av_fetch((AV *)SvRV(caller), 1, FALSE));
      }
      ap_log_error(file, line, APLOG_NOERRNO|level, 
  		 s, SvPV(msg,na));
      SvREFCNT_dec(msg);
  }
  
  #define join_stack_msg \
  SV *msgstr; \
  if(items > 2) { \
      msgstr = newSV(0); \
      do_join(msgstr, &sv_no, MARK+1, SP); \
  } \
  else { \
      msgstr = newSVsv(ST(1)); \
  } 
  
  #define MP_AP_LOG(l,s) \
  { \
  join_stack_msg; \
  ApacheLog(l, s, msgstr); \
  }
  
  #define Apache_log_emergency(s) \
  MP_AP_LOG(APLOG_EMERG, s)
  
  #define Apache_log_alert(s) \
  MP_AP_LOG(APLOG_ALERT, s)
  
  #define Apache_log_critical(s) \
  MP_AP_LOG(APLOG_CRIT, s)
  
  #define Apache_log_error(s) \
  MP_AP_LOG(APLOG_ERR, s)
  
  #define Apache_log_warn(s) \
  MP_AP_LOG(APLOG_WARNING, s)
  
  #define Apache_log_notice(s) \
  MP_AP_LOG(APLOG_NOTICE, s)
  
  #define Apache_log_info(s) \
  MP_AP_LOG(APLOG_INFO, s)
  
  #define Apache_log_debug(s) \
  MP_AP_LOG(APLOG_DEBUG, s)
  
  MODULE = Apache::Log		PACKAGE = Apache
  
  PROTOTYPES: DISABLE
  
  BOOT:
      items = items; /*avoid warning*/ 
  
  MODULE = Apache::Log		PACKAGE = Apache::Log PREFIX=Apache_log_
  
  void
  Apache_log_emergency(s, ...)
  	Apache::Server s
  
  void
  Apache_log_alert(s, ...)
  	Apache::Server s
  
  void
  Apache_log_critical(s, ...)
  	Apache::Server s
  
  void
  Apache_log_error(s, ...)
  	Apache::Server s
  
  void
  Apache_log_warn(s, ...)
  	Apache::Server s
  
  void
  Apache_log_notice(s, ...)
  	Apache::Server s
  
  void
  Apache_log_info(s, ...)
  	Apache::Server s
  
  void
  Apache_log_debug(s, ...)
  	Apache::Server s
  
  
  
  
  
  
  
  
  
  1.1                  modperl/t/modules/log.t
  
  Index: log.t
  ===================================================================
  
  use Apache::test;
  
  print fetch "http://$net::httpserver$net::perldir/log.pl";
  
  
  
  
  1.1                  modperl/t/net/perl/log.pl
  
  Index: log.pl
  ===================================================================
  use strict;
  use Apache::test;
  my $i = 0;
  my $r = shift;
  $r->send_http_header("text/plain");
  
  eval {
      require Apache::Log;
  };
  if($@) {
      print "$@\n";
      print "1..0\n";
      return;
  }
  
  my $rlog = $r->log;
  my $slog = $r->server->log;
  my @methods = qw{
  emergency
  alert
  critical
  error
  warn
  notice
  info
  debug
  };
  my $tests = @methods;
  print "1..$tests\n";
  for my $method (@methods)
  {
      $rlog->$method("Apache->method $method ", "OK");
      $slog->$method("Apache::Server->method $method ", "OK");
      print "method $method OK\n";
      test ++$i, 1;
  }
  
  
  
  

Mime
View raw message