X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=blobdiff_plain;f=lib%2FZOOM%2FIRSpy%2FWeb.pm;h=7f7dd9de8766a354e00cd7f29937c03fd52468de;hp=9ec823c7cd79c5afd4e594a4df18c1bc098a679a;hb=426f1dd0916ccd6901f76ed1edfe60051134e5b8;hpb=c4fc80fc378cd94241587bb451d5f919394641e5 diff --git a/lib/ZOOM/IRSpy/Web.pm b/lib/ZOOM/IRSpy/Web.pm index 9ec823c..7f7dd9d 100644 --- a/lib/ZOOM/IRSpy/Web.pm +++ b/lib/ZOOM/IRSpy/Web.pm @@ -1,4 +1,4 @@ -# $Id: Web.pm,v 1.1 2006-09-26 09:31:10 mike Exp $ +# $Id: Web.pm,v 1.5 2007-05-08 16:20:04 mike Exp $ package ZOOM::IRSpy::Web; @@ -9,7 +9,8 @@ use warnings; use ZOOM::IRSpy; our @ISA = qw(ZOOM::IRSpy); -use ZOOM::IRSpy::Record qw(xml_encode); +use ZOOM::IRSpy::Utils qw(xml_encode); + =head1 NAME @@ -19,18 +20,35 @@ ZOOM::IRSpy::Web - subclass of ZOOM::IRSpy for use by Web UI This behaves exactly the same as the base C class except that the Clog()> method does not call YAZ log, but outputs -HTML-formatted messages on standard output. +HTML-formatted messages on standard output. The additional function +log_init_level() controls what log-levels are to be included in the +output. Note that this arrangement only allows IRSpy-specific logging +to be generated, not underlying ZOOM logging. =cut +sub log_init_level { + my $this = shift(); + my($level) = @_; + + my $old = $this->{log_level}; + $this->{log_level} = $level if defined $level; + return $old; +} + sub log { my $this = shift(); my($level, @s) = @_; - # We should only produce output if $level is turned on + $this->{log_level} = "irspy" if !defined $this->{log_level}; + return if index(("," . $this->{log_level} . ","), ",$level,") < 0; + my $message = "[$level] " . join("", @s); $| = 1; # print xml_encode($message), "
\n"; + + ### This is naughty -- it knows about HTML::Mason + $HTML::Mason::Commands::m->flush_buffer(); }