Zoom-Meeting
view release on metacpan or search on metacpan
local/lib/perl5/Log/Message/Simple.pm view on Meta::CPAN
package Log::Message::Simple;
use if $] > 5.017, 'deprecate';
use strict;
use Log::Message private => 0;;
BEGIN {
use vars qw[$VERSION];
$VERSION = '0.10';
}
=pod
=head1 NAME
Log::Message::Simple - Simplified interface to Log::Message
=head1 SYNOPSIS
use Log::Message::Simple qw[msg error debug
carp croak cluck confess];
use Log::Message::Simple qw[:STD :CARP];
### standard reporting functionality
msg( "Connecting to database", $verbose );
error( "Database connection failed: $@", $verbose );
debug( "Connection arguments were: $args", $debug );
### standard carp functionality
carp( "Wrong arguments passed: @_" );
croak( "Fatal: wrong arguments passed: @_" );
cluck( "Wrong arguments passed -- including stacktrace: @_" );
confess("Fatal: wrong arguments passed -- including stacktrace: @_" );
### retrieve individual message
my @stack = Log::Message::Simple->stack;
my @stack = Log::Message::Simple->flush;
### retrieve the entire stack in printable form
my $msgs = Log::Message::Simple->stack_as_string;
my $trace = Log::Message::Simple->stack_as_string(1);
### redirect output
local $Log::Message::Simple::MSG_FH = \*STDERR;
local $Log::Message::Simple::ERROR_FH = \*STDERR;
local $Log::Message::Simple::DEBUG_FH = \*STDERR;
### force a stacktrace on error
local $Log::Message::Simple::STACKTRACE_ON_ERROR = 1
=head1 DESCRIPTION
This module provides standardized logging facilities using the
C<Log::Message> module.
=head1 FUNCTIONS
=head2 msg("message string" [,VERBOSE])
local/lib/perl5/Log/Message/Simple.pm view on Meta::CPAN
{ package Log::Message::Handlers;
sub msg {
my $self = shift;
my $verbose = shift || 0;
### so you don't want us to print the msg? ###
return if defined $verbose && $verbose == 0;
my $old_fh = select $Log::Message::Simple::MSG_FH;
print '['. $self->tag (). '] ' . $self->message . "\n";
select $old_fh;
return;
}
sub debug {
my $self = shift;
my $verbose = shift || 0;
### so you don't want us to print the msg? ###
return if defined $verbose && $verbose == 0;
my $old_fh = select $Log::Message::Simple::DEBUG_FH;
print '['. $self->tag (). '] ' . $self->message . "\n";
select $old_fh;
return;
}
sub error {
my $self = shift;
my $verbose = shift;
$verbose = 1 unless defined $verbose; # default to true
### so you don't want us to print the error? ###
return if defined $verbose && $verbose == 0;
my $old_fh = select $Log::Message::Simple::ERROR_FH;
my $msg = '['. $self->tag . '] ' . $self->message;
print $Log::Message::Simple::STACKTRACE_ON_ERROR
? Carp::shortmess($msg)
: $msg . "\n";
select $old_fh;
return;
}
}
=head2 carp();
local/lib/perl5/Log/Message/Simple.pm view on Meta::CPAN
=head2 cluck();
Provides functionality equal to C<Carp::cluck()> while still logging
to the stack.
Exported by using the C<:CARP> tag.
=head1 CLASS METHODS
=head2 Log::Message::Simple->stack()
Retrieves all the items on the stack. Since C<Log::Message::Simple> is
implemented using C<Log::Message>, consult its manpage for the
function C<retrieve> to see what is returned and how to use the items.
=head2 Log::Message::Simple->stack_as_string([TRACE])
Returns the whole stack as a printable string. If the C<TRACE> option is
true all items are returned with C<Carp::longmess> output, rather than
just the message.
C<TRACE> defaults to false.
=head2 Log::Message::Simple->flush()
Removes all the items from the stack and returns them. Since
C<Log::Message::Simple> is implemented using C<Log::Message>, consult its
manpage for the function C<retrieve> to see what is returned and how
to use the items.
=cut
BEGIN {
use Exporter;
use Params::Check qw[ check ];
use vars qw[ @EXPORT @EXPORT_OK %EXPORT_TAGS @ISA ];;
local/lib/perl5/Term/UI/History.pm view on Meta::CPAN
package Term::UI::History;
$Term::UI::History::VERSION = '0.50';
use strict;
use warnings;
use parent
qw! Exporter
Log::Message::Simple
!;
use Log::Message 'private' => 0;
our $HISTORY_FH = \ *STDOUT;
our @EXPORT = qw[ history ];
my $log = Log::Message->new();
=pod
local/lib/perl5/Term/UI/History.pm view on Meta::CPAN
local $Term::UI::History::HISTORY_FH = \*STDERR;
=head1 DESCRIPTION
This module provides the C<history> function for C<Term::UI>,
printing and saving all the C<UI> interaction.
Refer to the C<Term::UI> manpage for details on usage from
C<Term::UI>.
This module subclasses C<Log::Message::Simple>. Refer to its
manpage for additional functionality available via this package.
=head1 FUNCTIONS
=head2 history("message string" [,VERBOSE])
Records a message on the stack, and prints it to C<STDOUT>
(or actually C<$HISTORY_FH>, see the C<GLOBAL VARIABLES> section
below), if the C<VERBOSE> option is true.
local/lib/perl5/Term/UI/History.pm view on Meta::CPAN
=item $HISTORY_FH
This is the filehandle all the messages sent to C<history()> are being
printed. This defaults to C<*STDOUT>.
=back
=head1 See Also
C<Log::Message::Simple>, C<Term::UI>
=head1 AUTHOR
This module by
Jos Boumans E<lt>kane@cpan.orgE<gt>.
=head1 COPYRIGHT
This module is
copyright (c) 2005 Jos Boumans E<lt>kane@cpan.orgE<gt>.
( run in 0.454 second using v1.01-cache-2.11-cpan-a1d94b6210f )