dougm 01/05/03 16:46:08
Modified: t/response/TestAPI aplog.pm
xs/Apache/Log Apache__Log.h
xs/maps modperl_functions.map
Log:
add Apache::Server->log_serror and Apache::RequestRec->log_rerror methods
Revision Changes Path
1.4 +10 -0 modperl-2.0/t/response/TestAPI/aplog.pm
Index: aplog.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/aplog.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- aplog.pm 2001/05/03 22:42:26 1.3
+++ aplog.pm 2001/05/03 23:46:03 1.4
@@ -6,6 +6,7 @@
use Apache::Log ();
use Apache::Test;
use Apache::Const -compile => ':log';
+use APR::Const -compile => ':error';
my @LogLevels = qw(emerg alert crit error warn notice info debug);
my $package = __PACKAGE__;
@@ -35,6 +36,15 @@
ok sub { $rlog->can($method) };
ok sub { $slog->can($method) };
}
+
+ $s->log_serror(Apache::LOG_MARK, Apache::LOG_DEBUG, 0,
+ "log_serror test ok");
+
+ $s->log_serror(Apache::LOG_MARK, Apache::LOG_DEBUG,
+ APR::ENOTIME, "log_serror test 2 ok");
+
+ $r->log_rerror(Apache::LOG_MARK, Apache::LOG_DEBUG|Apache::LOG_NOERRNO,
+ APR::ENOTIME, "log_rerror test ok");
$s->loglevel(Apache::LOG_INFO);
$slog->debug(sub { die "set loglevel no workie" });
1.5 +56 -0 modperl-2.0/xs/Apache/Log/Apache__Log.h
Index: Apache__Log.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/Apache/Log/Apache__Log.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Apache__Log.h 2001/05/03 22:42:30 1.4
+++ Apache__Log.h 2001/05/03 23:46:05 1.5
@@ -182,3 +182,59 @@
PUSHs_mortal_iv(CopLINE(cop));
});
}
+
+static XS(MPXS_Apache__Log_log_error)
+{
+ dXSARGS;
+ SV *msgsv = Nullsv;
+ STRLEN n_a;
+ request_rec *r = NULL;
+ server_rec *s = NULL;
+ char *msgstr;
+ const char *file;
+ int line, level;
+ apr_status_t status;
+
+ if (items < 6) {
+ Perl_croak(aTHX_ "usage %s::%s(file, line, level, status, ...)",
+ mpxs_cv_name());
+ }
+
+ switch (*(GvNAME(CvGV(cv)) + 4)) { /* 4 == log_ */
+ case 'r':
+ r = modperl_xs_sv2request_rec(aTHX_ ST(0), NULL, cv);
+ break;
+ case 's':
+ s = (server_rec *)SvObjIV(ST(0));
+ break;
+ default:
+ croak_inval_obj();
+ };
+
+ file = (const char *)SvPV(ST(1), n_a);
+ line = (int)SvIV(ST(2));
+ level = (int)SvIV(ST(3));
+ status = (apr_status_t)SvIV(ST(4));
+
+ if (items > 6) {
+ msgsv = newSV(0);
+ do_join(msgsv, &PL_sv_no, MARK+5, SP);
+ }
+ else {
+ msgsv = ST(5);
+ (void)SvREFCNT_inc(msgsv);
+ }
+
+ msgstr = SvPV(msgsv, n_a);
+
+ if (r) {
+ ap_log_rerror(file, line, level, status, r, "%s", msgstr);
+ }
+ else {
+ ap_log_error(file, line, level, status, s, "%s", msgstr);
+ }
+
+ SvREFCNT_dec(msgsv);
+
+ XSRETURN_EMPTY;
+}
1.12 +4 -0 modperl-2.0/xs/maps/modperl_functions.map
Index: modperl_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- modperl_functions.map 2001/05/03 22:42:33 1.11
+++ modperl_functions.map 2001/05/03 23:46:07 1.12
@@ -45,9 +45,13 @@
PACKAGE=Apache::RequestRec
SV *:DEFINE_log | | SV *:obj
+SV *:DEFINE_log_rerror | MPXS_Apache__Log_log_error | ...
PACKAGE=Apache::Server
SV *:DEFINE_log | | SV *:obj
+#using `log_serror' rather than `log_error' to avoid name conflict
+#with 1.xx version
+SV *:DEFINE_log_serror | MPXS_Apache__Log_log_error | ...
PACKAGE=Apache