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