X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=lib%2FZOOM%2FIRSpy%2FWeb.pm;h=f99ae6704a3924d3bb14f407d70ad0c10f48e83e;hb=4f36c963da80271ffea671999e41aaa04ea9a36f;hp=9ec823c7cd79c5afd4e594a4df18c1bc098a679a;hpb=42df1e0ffaa38a2beb1186b5bcd2988a43d444c7;p=irspy-moved-to-github.git diff --git a/lib/ZOOM/IRSpy/Web.pm b/lib/ZOOM/IRSpy/Web.pm index 9ec823c..f99ae67 100644 --- a/lib/ZOOM/IRSpy/Web.pm +++ b/lib/ZOOM/IRSpy/Web.pm @@ -1,4 +1,3 @@ -# $Id: Web.pm,v 1.1 2006-09-26 09:31:10 mike Exp $ package ZOOM::IRSpy::Web; @@ -9,7 +8,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 +19,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(); }