test debugging
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Web.pm
1 # $Id: Web.pm,v 1.5 2007-05-08 16:20:04 mike Exp $
2
3 package ZOOM::IRSpy::Web;
4
5 use 5.008;
6 use strict;
7 use warnings;
8
9 use ZOOM::IRSpy;
10 our @ISA = qw(ZOOM::IRSpy);
11
12 use ZOOM::IRSpy::Utils qw(xml_encode);
13
14
15 =head1 NAME
16
17 ZOOM::IRSpy::Web - subclass of ZOOM::IRSpy for use by Web UI
18
19 =head1 DESCRIPTION
20
21 This behaves exactly the same as the base C<ZOOM::IRSpy> class except
22 that the Clog()> method does not call YAZ log, but outputs
23 HTML-formatted messages on standard output.  The additional function
24 log_init_level() controls what log-levels are to be included in the
25 output.  Note that this arrangement only allows IRSpy-specific logging
26 to be generated, not underlying ZOOM logging.
27
28 =cut
29
30 sub log_init_level {
31     my $this = shift();
32     my($level) = @_;
33
34     my $old = $this->{log_level};
35     $this->{log_level} = $level if defined $level;
36     return $old;
37 }
38
39 sub log {
40     my $this = shift();
41     my($level, @s) = @_;
42
43     $this->{log_level} = "irspy" if !defined $this->{log_level};
44     return if index(("," . $this->{log_level} . ","), ",$level,") < 0;
45
46     my $message = "[$level] " . join("", @s);
47     $| = 1;                     # 
48     print xml_encode($message), "<br/>\n";
49
50     ### This is naughty -- it knows about HTML::Mason
51     $HTML::Mason::Commands::m->flush_buffer();
52 }
53
54
55 =head1 SEE ALSO
56
57 ZOOM::IRSpy
58
59 =head1 AUTHOR
60
61 Mike Taylor, E<lt>mike@indexdata.comE<gt>
62
63 =head1 COPYRIGHT AND LICENSE
64
65 Copyright (C) 2006 by Index Data ApS.
66
67 This library is free software; you can redistribute it and/or modify
68 it under the same terms as Perl itself, either Perl version 5.8.7 or,
69 at your option, any later version of Perl 5 you may have available.
70
71 =cut
72
73 1;