Author: dylan
Date: 2005-01-23 01:35:30 -0500 (Sun, 23 Jan 2005)
New Revision: 604
Added:
trunk/main/core/lib/Haver/Logger.pm
trunk/main/core/lib/Haver/Logger/
trunk/main/core/lib/Haver/Logger/Dummy.pm
trunk/main/core/lib/Haver/Logger/Functions.pm
trunk/main/core/t/001_config.t
trunk/main/core/t/002_protocol.t
trunk/main/core/t/003_logger.t
Removed:
trunk/main/core/t/config.t
trunk/main/core/t/protocol.t
Log:
Haver::Logger created. :)
Added: trunk/main/core/lib/Haver/Logger/Dummy.pm
===================================================================
--- trunk/main/core/lib/Haver/Logger/Dummy.pm 2005-01-23 04:38:06 UTC (rev
603)
+++ trunk/main/core/lib/Haver/Logger/Dummy.pm 2005-01-23 06:35:30 UTC (rev
604)
@@ -0,0 +1,68 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package Haver::Logger::Dummy;
+use strict;
+use warnings;
+
+our $VERSION = 0.01;
+use base 'Haver::Base';
+
+sub AUTOLOAD { return }
+
+
+1;
+__END__
+
+=head1 NAME
+
+Haver::Logger::Dummy - description
+
+=head1 SYNOPSIS
+
+ use Haver::Logger::Dummy
+ # Small code example.
+
+=head1 DESCRIPTION
+
+FIXME
+
+
+=head1 INHERITENCE
+
+Haver::Logger::Dummy extends L<Haver::Base>.
+
+=head1 METHODS
+
+This is a black hole class that ignores all method calls.
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<http://www.haverdev.org/>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2005 by Dylan William Hardison. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Added: trunk/main/core/lib/Haver/Logger/Functions.pm
===================================================================
--- trunk/main/core/lib/Haver/Logger/Functions.pm 2005-01-23 04:38:06 UTC
(rev 603)
+++ trunk/main/core/lib/Haver/Logger/Functions.pm 2005-01-23 06:35:30 UTC
(rev 604)
@@ -0,0 +1,95 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package Haver::Logger::Functions;
+use strict;
+use warnings;
+
+use base 'Exporter';
+
+our $VERSION = 0.03;
+our @EXPORT_OK = qw( err crit emerg );
+
+{
+ no strict 'refs';
+ my @functions = qw(
+ debug info
+ notice warning
+ error critical
+ alert emergency
+ );
+ foreach my $func (@functions) {
+ *$func = sub {
+ $Logger->log(level => $func, message => $_[0]);
+ };
+ push @EXPORT_OK, $func;
+ }
+}
+
+*crit = \&critical;
+*err = \&error;
+
+
+1;
+__END__
+
+=head1 NAME
+
+Haver::Logger::Functions - Functional interface to Haver::Logger.
+
+=head1 SYNOPSIS
+
+ use Haver::Logger::Functions
+ # Small code example.
+
+=head1 DESCRIPTION
+
+FIXME
+
+
+=head1 INHERITENCE
+
+Haver::Logger::Functions extends L<Haver::Base>.
+
+=head1 CONSTRUCTOR
+
+List required parameters for new().
+
+=head1 METHODS
+
+This class implements the following methods:
+
+=head1 method1(Z<>)
+
+...
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<perl(1)>, and any other related modules / manpages / websites.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2005 by Dylan William Hardison. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Added: trunk/main/core/lib/Haver/Logger.pm
===================================================================
--- trunk/main/core/lib/Haver/Logger.pm 2005-01-23 04:38:06 UTC (rev 603)
+++ trunk/main/core/lib/Haver/Logger.pm 2005-01-23 06:35:30 UTC (rev 604)
@@ -0,0 +1,93 @@
+# vim: set ts=4 sw=4 expandtab si ai sta tw=100:
+# This module is copyrighted, see end of file for details.
+package Haver::Logger;
+use strict;
+use warnings;
+use Carp;
+
+our $VERSION = 0.02;
+our @ISA;
+my $Self;
+
+eval { require Log::Dispatch };
+
+if ($@ or $Haver::Logger::Dummy) {
+ require Haver::Logger::Dummy;
+ push @ISA, 'Haver::Logger::Dummy';
+} else {
+ push @ISA, 'Log::Dispatch';
+}
+
+sub new {
+ croak __PACKAGE__ . ": Singleton class, use instance() instead.";
+}
+
+sub instance {
+ return $Self if $Self;
+ return $Self = shift->SUPER::new();
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Haver::Logger - Haver subclass of L<Log::Dispatch>
+
+=head1 SYNOPSIS
+
+ use Haver::Logger;
+ # Small code example.
+
+=head1 DESCRIPTION
+
+This is a wrapper around L<Log::Dispatch>, making Log::Dispatch
+optional.
+
+=head1 INHERITENCE
+
+Haver::Logger extends either L<Log::Dispatch> or L<Haver::Logger::Dummy>.
+
+=head1 METHODS
+
+Haver::Logger implements the following methods:
+
+=head2 new(Z<>)
+
+Don't call this method, ever. It will throw an exception.
+
+=head2 instance(Z<>)
+
+Returns the (singleton) Haver::Logger object.
+
+=head1 BUGS
+
+None known. Bug reports are welcome. Please use our bug tracker at
+L<http://gna.org/bugs/?func=additem&group=haver>.
+
+=head1 AUTHOR
+
+Dylan William Hardison, E<lt>[EMAIL PROTECTED]<gt>
+
+=head1 SEE ALSO
+
+L<http://www.haverdev.org/>.
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2005 by Dylan William Hardison. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This module is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this module; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Copied: trunk/main/core/t/001_config.t (from rev 599,
trunk/main/core/t/config.t)
Copied: trunk/main/core/t/002_protocol.t (from rev 599,
trunk/main/core/t/protocol.t)
Added: trunk/main/core/t/003_logger.t
===================================================================
--- trunk/main/core/t/003_logger.t 2005-01-23 04:38:06 UTC (rev 603)
+++ trunk/main/core/t/003_logger.t 2005-01-23 06:35:30 UTC (rev 604)
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+# vim: set ft=perl:
+
+use strict;
+use Test::More tests => 2;
+BEGIN {
+ use_ok('Haver::Logger');
+};
+
+#########################
+
+eval { new Haver::Logger };
+if ($@) {
+ pass("new is a fatal error.");
+} else {
+ fail("new is not a fatal error!");
+}
+
+
Deleted: trunk/main/core/t/config.t
===================================================================
--- trunk/main/core/t/config.t 2005-01-23 04:38:06 UTC (rev 603)
+++ trunk/main/core/t/config.t 2005-01-23 06:35:30 UTC (rev 604)
@@ -1,27 +0,0 @@
-#!/usr/bin/perl
-# vim: set ft=perl:
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use Test::More tests => 3;
-BEGIN {
- use_ok('Haver::Config');
-};
-
-can_ok('Haver::Config', 'new', 'config');
-
-my $d =
-my $ch = new Haver::Config (
- file => 'foobar',
- default => {
- stuff => {
- monkeys => 2,
- },
- foo => 'bar',
- },
-);
-my $c = $ch->config;
-
-is_deeply($c, { stuff => { monkeys => 2 }, foo => 'bar' }, "Config with
default values");
Deleted: trunk/main/core/t/protocol.t
===================================================================
--- trunk/main/core/t/protocol.t 2005-01-23 04:38:06 UTC (rev 603)
+++ trunk/main/core/t/protocol.t 2005-01-23 06:35:30 UTC (rev 604)
@@ -1,31 +0,0 @@
-#!/usr/bin/perl
-# vim: set ft=perl:
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl Haver.t'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use Test::More tests => 6;
-BEGIN {
- use_ok('Haver');
- use_ok('Haver::Protocol', qw(:event :crlf :escape));
-};
-
-#########################
-
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
-{
- my $s = "bunnies\et\eet\er\en";
- is(escape(unescape($s)), $s, "escape and unescape work properly");
-}
-{
- my $in = ["This", "is", "a test", "of \r\e\n\t"];
- my $out = "This\tis\ta test\tof \er\ee\en\et$CRLF";
- is(event2line($in), $out, "event2line");
- is_deeply([line2event($out)], $in, "line2event");
- is(event2line(line2event($out)), $out, "input is output");
-}
-