export $debug and control warn output
[Biblio-RFID.git] / lib / RFID / Biblio.pm
index daccc32..88014a4 100644 (file)
@@ -4,7 +4,7 @@ use warnings;
 use strict;
 
 use base 'Exporter';
-our @EXPORT = qw( hex2bytes as_hex hex_tag );
+our @EXPORT = qw( hex2bytes as_hex hex_tag $debug );
 
 use Data::Dump qw(dump);
 
@@ -16,7 +16,7 @@ RFID::Biblio - perl tools to use different RFID readers for library use
 
 our $VERSION = '0.02';
 
-my $debug = 0;
+our $debug = 0;
 
 
 =head1 DESCRIPTION
@@ -56,6 +56,9 @@ C<examples/koha-rfid.js> is jQuery based JavaScript code which can be inserted
 in Koha Library System to provide overlay with tags in range and
 check-in/check-out form-fill functionality.
 
+Applications can use L<RFID::Biblio::RFID501> which is some kind of
+semi-standard 3M layout or blocks on RFID tags.
+
 =for readme stop
 
 =head1 EXPORT
@@ -105,6 +108,24 @@ sub as_hex {
 
 sub hex_tag { uc(unpack('H16', shift)) }
 
+=head1 WARN
+
+We are installing L<perldoc/warn> handler to controll debug output
+based on C<$Biblio::RFID::debug> level
+
+=cut
+
+BEGIN {
+       $SIG{'__WARN__'} = sub {
+               my $msg = join(' ', @_);
+               if ( $msg =~ m/^(#+)/ ) {
+                       my $l = length $1;
+                       return if $l > $debug;
+               }
+               warn join(' ', @_);
+       }
+}
+
 =for readme continue
 
 =head1 HARDWARE SUPPORT
@@ -126,6 +147,8 @@ L<RFID::Biblio::Reader::librfid>
 
 Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
 
+L<http://blog.rot13.org/>
+
 =head1 BUGS
 
 Please report any bugs or feature requests to C<bug-rfid-biblio at rt.cpan.org>, or through