1###########################################################################
2#
3#   Silent.pm
4#
5#   Copyright (C) 1999 Raphael Manfredi.
6#   Copyright (C) 2002-2017 Mark Rogaski, mrogaski@cpan.org;
7#   all rights reserved.
8#
9#   See the README file included with the
10#   distribution for license information.
11#
12##########################################################################
13
14use strict;
15require Log::Agent::Driver;
16
17########################################################################
18package Log::Agent::Driver::Silent;
19
20use vars qw(@ISA);
21
22@ISA = qw(Log::Agent::Driver);
23
24#
25# ->make			-- defined
26#
27# Creation routine.
28#
29sub make {
30	my $self = bless {}, shift;
31	return $self;
32}
33
34#
35# NOP routines.
36#
37
38sub prefix_msg {}
39sub emit {}
40sub channel_eq { 1 }
41
42#
43# In theory, we could live with the above NOP ops and the logxxx()
44# routines would not do anything. Let's redefine them though...
45#
46
47sub logerr   {}
48sub logwarn  {}
49sub logcluck {}
50sub logsay   {}
51sub loginfo  {}
52sub logdebug {}
53sub logwrite {}
54sub logxcarp {}
55
56#
57# Those need minimal processing.
58# We explicitely stringify the string argument (uses overloaded "" method)
59#
60
61sub logconfess { require Carp; Carp::confess("$_[1]"); }
62sub logdie     { die "$_[0]\n"; }
63
64#
65# ->logxcroak		-- redefined
66#
67# Handle the offset parameter correctly
68#
69sub logxcroak  {
70	my $self = shift;
71	my ($offset, $str) = @_;
72	require Carp;
73	my $msg = $self->carpmess($offset, $str, \&Carp::shortmess);
74	die "$msg\n";
75}
76
771;	# for require
78__END__
79
80=head1 NAME
81
82Log::Agent::Driver::Silent - silent logging driver for Log::Agent
83
84=head1 SYNOPSIS
85
86 use Log::Agent;
87 require Log::Agent::Driver::Silent;
88
89 my $driver = Log::Agent::Driver::Silent->make();
90 logconfig(-driver => $driver);
91
92=head1 DESCRIPTION
93
94The silent logging driver remaps most of the logxxx() operations to NOPs.
95Only logconfess() and logdie() respectively call Carp::confess() and die().
96
97=head1 CHANNELS
98
99All the channels go to /dev/null, so to speak.
100
101=head1 AUTHOR
102
103Raphael Manfredi F<E<lt>Raphael_Manfredi@pobox.comE<gt>>
104
105=head1 SEE ALSO
106
107Log::Agent::Driver(3), Log::Agent(3).
108
109=cut
110