Log::Agent::Driver::Silent - silent logging driver for Log::Agent


Log-Agent documentation Contained in the Log-Agent distribution.

Index


Code Index:

NAME

Top

Log::Agent::Driver::Silent - silent logging driver for Log::Agent

SYNOPSIS

Top

 use Log::Agent;
 require Log::Agent::Driver::Silent;

 my $driver = Log::Agent::Driver::Silent->make();
 logconfig(-driver => $driver);

DESCRIPTION

Top

The silent logging driver remaps most of the logxxx() operations to NOPs. Only logconfess() and logdie() respectively call Carp::confess() and die().

CHANNELS

Top

All the channels go to /dev/null, so to speak.

AUTHOR

Top

Raphael Manfredi <Raphael_Manfredi@pobox.com>

SEE ALSO

Top

Log::Agent::Driver(3), Log::Agent(3).


Log-Agent documentation Contained in the Log-Agent distribution.

#
# $Id: Silent.pm,v 1.1 2002/03/09 15:54:27 wendigo Exp $
#
#  Copyright (c) 1999, Raphael Manfredi
#  
#  You may redistribute only under the terms of the Artistic License,
#  as specified in the README file that comes with the distribution.
#
# HISTORY
# $Log: Silent.pm,v $
# Revision 1.1  2002/03/09 15:54:27  wendigo
# New maintainer
#
# Revision 0.2  2000/11/06 19:30:33  ram
# Baseline for second Alpha release.
#
# $EndLog$
#

use strict;
require Log::Agent::Driver;

########################################################################
package Log::Agent::Driver::Silent;

use vars qw(@ISA);

@ISA = qw(Log::Agent::Driver);

#
# ->make			-- defined
#
# Creation routine.
#
sub make {
	my $self = bless {}, shift;
	return $self;
}

#
# NOP routines.
#

sub prefix_msg {}
sub emit {}
sub channel_eq { 1 }

#
# In theory, we could live with the above NOP ops and the logxxx()
# routines would not do anything. Let's redefine them though...
#

sub logerr {}
sub logwarn {}
sub logsay {}
sub logwrite {}
sub logxcarp {}

#
# Those need minimal processing.
# We explicitely stringify the string argument (uses overloaded "" method)
#

sub logconfess { require Carp; Carp::confess("$_[1]"); }
sub logdie     { die "$_[0]\n"; }

#
# ->logxcroak		-- redefined
#
# Handle the offset parameter correctly
#
sub logxcroak  {
	my $self = shift;
	my ($offset, $str) = @_;
	require Carp;
	my $msg = $self->carpmess($offset, $str, \&Carp::shortmess);
	die "$msg\n";
}

1;	# for require
__END__