From 3f8b87b2e4c81c1d469acaaf37d7f4ac59ff3d1b Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 26 Sep 2006 11:25:07 +0000 Subject: [PATCH] Add log_init_level() log() now calls $m->flush_buffer() directly. --- lib/ZOOM/IRSpy/Web.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/ZOOM/IRSpy/Web.pm b/lib/ZOOM/IRSpy/Web.pm index 9ec823c..d2bd4ef 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.2 2006-09-26 11:25:07 mike Exp $ package ZOOM::IRSpy::Web; @@ -19,18 +19,34 @@ 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. =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(); } -- 1.7.10.4