From: Mike Taylor Date: Tue, 26 Sep 2006 11:25:07 +0000 (+0000) Subject: Add log_init_level() X-Git-Tag: CPAN-v1.02~54^2~974 X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=commitdiff_plain;h=3f8b87b2e4c81c1d469acaaf37d7f4ac59ff3d1b;hp=cc122c38c4f88dffc611c1dd32236fd78a6a8dd6 Add log_init_level() log() now calls $m->flush_buffer() directly. --- 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(); }