Skip to content

Commit

Permalink
Initial entry of Null Handle
Browse files Browse the repository at this point in the history
Initial entry of Null Handle and associated unit tests.
  • Loading branch information
cfuhrman committed Jun 29, 2012
1 parent 559ebfb commit c2b7887
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 4 deletions.
2 changes: 2 additions & 0 deletions MANIFEST
Expand Up @@ -16,6 +16,7 @@ lib/Log/Fine/Handle/Console.pm
lib/Log/Fine/Handle/Email.pm
lib/Log/Fine/Handle/File.pm
lib/Log/Fine/Handle/File/Timestamp.pm
lib/Log/Fine/Handle/Null.pm
lib/Log/Fine/Handle/Syslog.pm
lib/Log/Fine/Handle/String.pm
lib/Log/Fine/Levels.pm
Expand All @@ -42,6 +43,7 @@ t/14-handle-syslog-log_user.t
t/15-handle-email.t
t/16-handle-email-smtp.t
t/17-handle-file-windows.t
t/18-handle-null.t
t/boilerplate.t
t/pod-coverage.t
t/pod.t
111 changes: 111 additions & 0 deletions lib/Log/Fine/Handle/Null.pm
@@ -0,0 +1,111 @@

=head1 NAME
Log::Fine::Handle::Null - Output messages to nowhere
=head1 SYNOPSIS
Provides logging to nowhere in particular
use Log::Fine::Handle::Null;
use Log::Fine::Levels::Syslog qw( :masks );
# Create a new handle
my $handle = Log::Fine::Handle::Null
->new( name => "devnull",
mask => LOGMASK_DEBUG | LOGMASK_INFO | LOGMASK_NOTICE
);
# This is a no-op
$handle->msgWrite(INFO, "Goes Nowhere. Does Nothing.");
=head1 DESCRIPTION
The null handle provides logging to C</dev/null> (a.k.a. C</NUL>).
=cut

use strict;
use warnings;

package Log::Fine::Handle::Null;

use base qw( Log::Fine::Handle );

use Log::Fine;

our $VERSION = $Log::Fine::Handle::VERSION;

=head1 METHODS
=head2 msgWrite
See L<Log::Fine::Handle/msgWrite>
=cut

sub msgWrite { return $_[0]; } # msgWrite()

=head1 BUGS
Please report any bugs or feature requests to
C<bug-log-fine at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-Fine>.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Log::Fine
You can also look for information at:
=over 4
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Log-Fine>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/Log-Fine>
=item * RT: CPAN's request tracker
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Fine>
=item * Search CPAN
L<http://search.cpan.org/dist/Log-Fine>
=back
=head1 REVISION INFORMATION
$Id$
=head1 AUTHOR
Christopher M. Fuhrman, C<< <cfuhrman at panix.com> >>
=head1 SEE ALSO
L<perl>, L<Log::Fine::Handle>
=head1 COPYRIGHT & LICENSE
Copyright (c) 2012 Christopher M. Fuhrman,
All rights reserved.
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the
LICENSE file included with this module.
=cut

1; # End of Log::Fine::Handle::Null
5 changes: 3 additions & 2 deletions t/00-load.t
@@ -1,6 +1,6 @@
#!perl -T

use Test::More tests => 18;
use Test::More tests => 19;

BEGIN {
use_ok('Log::Fine');
Expand All @@ -10,9 +10,10 @@ BEGIN {
use_ok('Log::Fine::Formatter::Syslog');
use_ok('Log::Fine::Formatter::Template');
use_ok('Log::Fine::Handle');
use_ok('Log::Fine::Handle::Console');
use_ok('Log::Fine::Handle::File');
use_ok('Log::Fine::Handle::File::Timestamp');
use_ok('Log::Fine::Handle::Console');
use_ok('Log::Fine::Handle::Null');
use_ok('Log::Fine::Handle::Syslog');
use_ok('Log::Fine::Handle::String');
use_ok('Log::Fine::Levels');
Expand Down
29 changes: 29 additions & 0 deletions t/18-handle-null.t
@@ -0,0 +1,29 @@
#!perl -T

#
# $Id$
#

use Test::More tests => 3;

use Log::Fine;
use Log::Fine::Handle::Null;
use Log::Fine::Levels::Syslog qw( :masks );

{

my $handle =
Log::Fine::Handle::Null->new(
name => "devnull",
mask => LOGMASK_DEBUG | LOGMASK_INFO | LOGMASK_NOTICE
);

isa_ok($handle, "Log::Fine::Handle::Null");
can_ok($handle, "msgWrite");

my $return_value =
$handle->msgWrite(INFO, "Goes Nowhere. Does Nothing.");

isa_ok($handle, "Log::Fine::Handle::Null");

}
5 changes: 3 additions & 2 deletions t/boilerplate.t
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
use Test::More tests => 20;
use Test::More tests => 21;

sub not_in_file_ok
{
Expand Down Expand Up @@ -53,10 +53,11 @@ module_boilerplate_ok('lib/Log/Fine/Formatter/Detailed.pm');
module_boilerplate_ok('lib/Log/Fine/Formatter/Syslog.pm');
module_boilerplate_ok('lib/Log/Fine/Formatter/Template.pm');
module_boilerplate_ok('lib/Log/Fine/Handle.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/Console.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/Email.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/File.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/File/Timestamp.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/Console.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/Null.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/Syslog.pm');
module_boilerplate_ok('lib/Log/Fine/Handle/String.pm');
module_boilerplate_ok('lib/Log/Fine/Levels.pm');
Expand Down

0 comments on commit c2b7887

Please sign in to comment.