From b9eea3a2ebd3feae59bc8c01a70dbe8b9e0b807a Mon Sep 17 00:00:00 2001 From: pop Date: Wed, 7 May 2003 20:51:12 +0000 Subject: [PATCH] Added log prefix features. Fixed handling of "0" values in data1. Session.pm is using Carp now. --- perl/IDZebra.i | 15 ++++++++++-- perl/IDZebra_wrap.c | 56 ++++++++++++++++++++++++++++++++++++++++--- perl/lib/IDZebra.pm | 2 ++ perl/lib/IDZebra/Data1.pm | 2 +- perl/lib/IDZebra/Session.pm | 5 ++-- perl/zebra_perl.c | 8 ------- 6 files changed, 72 insertions(+), 16 deletions(-) diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 6a9c75d..3878c04 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -149,10 +149,21 @@ void DESTROY (void); /* == Logging facilities (yaz/log.h) ======================================= */ -void logLevel (int level); -void logFile (const char *fname); +%name(logLevel) +void yaz_log_init_level (int level); + +%name(logFile) +void yaz_log_init_file (const char *fname); + +%name(logMsg) void logMsg (int level, const char *message); +%name(logPrefix) +void yaz_log_init_prefix (const char *prefix); + +%name(logPrefix2) +void yaz_log_init_prefix2 (const char *prefix); + #define LOG_FATAL 0x0001 #define LOG_DEBUG 0x0002 #define LOG_WARN 0x0004 diff --git a/perl/IDZebra_wrap.c b/perl/IDZebra_wrap.c index e147810..256cfac 100644 --- a/perl/IDZebra_wrap.c +++ b/perl/IDZebra_wrap.c @@ -212,7 +212,7 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { * perl5.swg * * Perl5 runtime library - * $Header: /home/cvsroot/idis/perl/Attic/IDZebra_wrap.c,v 1.16 2003-03-13 04:25:17 pop Exp $ + * $Header: /home/cvsroot/idis/perl/Attic/IDZebra_wrap.c,v 1.17 2003-05-07 20:51:12 pop Exp $ * ----------------------------------------------------------------------------- */ #define SWIGPERL @@ -3010,7 +3010,7 @@ XS(_wrap_logLevel) { SWIG_croak("Usage: logLevel(level);"); } arg1 = (int) SvIV(ST(0)); - logLevel(arg1); + yaz_log_init_level(arg1); XSRETURN(argvi); @@ -3034,7 +3034,7 @@ XS(_wrap_logFile) { } if (!SvOK((SV*) ST(0))) arg1 = 0; else arg1 = (char *) SvPV(ST(0), PL_na); - logFile((char const *)arg1); + yaz_log_init_file((char const *)arg1); XSRETURN(argvi); @@ -3071,6 +3071,54 @@ XS(_wrap_logMsg) { } +XS(_wrap_logPrefix) { + char _swigmsg[SWIG_MAX_ERRMSG] = ""; + const char *_swigerr = _swigmsg; + { + char *arg1 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: logPrefix(prefix);"); + } + if (!SvOK((SV*) ST(0))) arg1 = 0; + else arg1 = (char *) SvPV(ST(0), PL_na); + yaz_log_init_prefix((char const *)arg1); + + + XSRETURN(argvi); + fail: + (void) _swigerr; + } + croak(_swigerr); +} + + +XS(_wrap_logPrefix2) { + char _swigmsg[SWIG_MAX_ERRMSG] = ""; + const char *_swigerr = _swigmsg; + { + char *arg1 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: logPrefix2(prefix);"); + } + if (!SvOK((SV*) ST(0))) arg1 = 0; + else arg1 = (char *) SvPV(ST(0), PL_na); + yaz_log_init_prefix2((char const *)arg1); + + + XSRETURN(argvi); + fail: + (void) _swigerr; + } + croak(_swigerr); +} + + XS(_wrap_odr_createmem) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; @@ -8492,6 +8540,8 @@ static swig_command_info swig_commands[] = { {"IDZebrac::logLevel", _wrap_logLevel}, {"IDZebrac::logFile", _wrap_logFile}, {"IDZebrac::logMsg", _wrap_logMsg}, +{"IDZebrac::logPrefix", _wrap_logPrefix}, +{"IDZebrac::logPrefix2", _wrap_logPrefix2}, {"IDZebrac::odr_createmem", _wrap_odr_createmem}, {"IDZebrac::odr_reset", _wrap_odr_reset}, {"IDZebrac::odr_destroy", _wrap_odr_destroy}, diff --git a/perl/lib/IDZebra.pm b/perl/lib/IDZebra.pm index 927e004..b4a5009 100644 --- a/perl/lib/IDZebra.pm +++ b/perl/lib/IDZebra.pm @@ -37,6 +37,8 @@ package IDZebra; *logLevel = *IDZebrac::logLevel; *logFile = *IDZebrac::logFile; *logMsg = *IDZebrac::logMsg; +*logPrefix = *IDZebrac::logPrefix; +*logPrefix2 = *IDZebrac::logPrefix2; *odr_createmem = *IDZebrac::odr_createmem; *odr_reset = *IDZebrac::odr_reset; *odr_destroy = *IDZebrac::odr_destroy; diff --git a/perl/lib/IDZebra/Data1.pm b/perl/lib/IDZebra/Data1.pm index 9aa54ff..1a36216 100644 --- a/perl/lib/IDZebra/Data1.pm +++ b/perl/lib/IDZebra/Data1.pm @@ -103,7 +103,7 @@ sub tag_add_attr { sub mk_text { my ($self, $parent, $text) = @_; - $text = "" unless ($text); + $text = "" unless defined ($text); return (IDZebra::data1_mk_text($self->{dh}, $self->{mem}, $text, $parent)); } diff --git a/perl/lib/IDZebra/Session.pm b/perl/lib/IDZebra/Session.pm index a98a232..57dc36a 100644 --- a/perl/lib/IDZebra/Session.pm +++ b/perl/lib/IDZebra/Session.pm @@ -1,4 +1,4 @@ -# $Id: Session.pm,v 1.15 2003-03-13 04:25:18 pop Exp $ +# $Id: Session.pm,v 1.16 2003-05-07 20:51:12 pop Exp $ # # Zebra perl API header # ============================================================================= @@ -6,6 +6,7 @@ package IDZebra::Session; use strict; use warnings; +use Carp; BEGIN { use IDZebra; @@ -15,7 +16,7 @@ BEGIN { use IDZebra::ScanList; use IDZebra::RetrievalRecord; require Exporter; - our $VERSION = do { my @r = (q$Revision: 1.15 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.16 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our @ISA = qw(IDZebra::Logger Exporter); our @EXPORT = qw (TRANS_RW TRANS_RO); } diff --git a/perl/zebra_perl.c b/perl/zebra_perl.c index b097531..3024d4b 100644 --- a/perl/zebra_perl.c +++ b/perl/zebra_perl.c @@ -29,14 +29,6 @@ void DESTROY (void) { } /* Logging facilities from yaz */ -void logLevel (int level) { - yaz_log_init_level(level); -} - -void logFile (const char *fname) { - yaz_log_init_file(fname); -} - void logMsg (int level, const char *message) { logf(level, "%s", message); } -- 1.7.10.4