Log-Message-Simple
view release on metacpan or search on metacpan
Changes for 0.10 Wed Jan 23 08:10:42 GMT 2013
================================================
* Add deprecate usage to warn if module is loaded
from corelib. Log::Message::Simple is leaving
core with v5.20.0, but will still be available
on CPAN.
Changes for 0.08 Wed Jan 19 10:22:12 2011
============================================
* POD fix from Michael Stevens [rt.cpan.org #64877]
Changes for 0.06 Fri Sep 11 07:17:57 2009
============================================
* Abstract fix in POD. Resolves RT #49562
Changes for 0.04 Mon Oct 22 14:10:23 2007
============================================
* Documentation nits. Users of 0.02 are not
required to upgrade.
Changes for 0.02 Mon May 28 11:46:52 2007
============================================
* This is an administrative update only: Users do not
need to upgrade.
* As of perl 5.9.5, Log::Message::Simple is part
of core perl and should be installed in the 'perl'
dir rather than the 'site' dir.
* Improve test suite under perl core tests
* Quell some test warnings
Makefile.PL view on Meta::CPAN
my @LICENSE;
push @LICENSE, 'LICENSE', 'perl' if $ExtUtils::MakeMaker::VERSION > 6.30;
WriteMakefile1(
META_MERGE => {
resources => {
repository => 'git://github.com/jib/log-message-simple.git',
},
},
NAME => 'Log::Message::Simple',
VERSION_FROM => 'lib/Log/Message/Simple.pm', # finds $VERSION
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' },
PREREQ_PM => { 'Carp' => 0,
'Test::More' => 0,
'Log::Message' => 0,
'if' => 0,
},
INSTALLDIRS => ( $] >= 5.009005 && $] < 5.012 ? 'perl' : 'site' ),
AUTHOR => 'Jos Boumans <kane[at]cpan.org>',
ABSTRACT => 'Simplified interface to Log::Message',
This is the README file for Log::Message::Simple, a simplified frontend
to Log::Message (a small and powerful generic message logging module)
Please type "perldoc Log::Message::Simple" after installation to see
the module usage information.
#####################################################################
* Description
Log::Message::Simple
This module is a simplified frontend to Log::Message, offering
most common use for logging, and easy access to the stack (in
both raw and pretty-printable form).
See the Log::Message::Simple manpage, and the Log::Message
module for details.
#####################################################################
* Installation
Log::Message uses the standard perl module install process:
perl Makefile.PL
lib/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])
lib/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();
lib/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 ];;
use Test::More 'no_plan';
use strict;
my $Class = 'Log::Message::Simple';
use_ok( $Class );
diag( "Testing $Class version " . $Class->VERSION ) unless $ENV{PERL_CORE};
t/02_imports.t view on Meta::CPAN
use Test::More 'no_plan';
use strict;
my $Class = 'Log::Message::Simple';
my @Carp = qw[carp croak cluck confess];
my @Msg = qw[msg debug error];
### test empty import
{ package Test::A;
eval "use $Class ()";
t/03_functions.t view on Meta::CPAN
use Test::More 'no_plan';
use strict;
my $Class = 'Log::Message::Simple';
my @Carp = qw[carp croak cluck confess];
my @Msg = qw[msg debug error];
my $Text = 'text';
my $Pkg = 'Test::A';
use_ok( $Class );
{ package Test::A;
### set up local equivalents to exported functions
t/03_functions.t view on Meta::CPAN
### about warnings
### close stderr/warnings for that same purpose, as carp
### & friends will print there
for my $name (@Carp, @Msg) {
no strict 'refs';
*$name = sub {
local $^W;
### do the block twice to avoid 'used only once'
### warnings
local $Log::Message::Simple::ERROR_FH;
local $Log::Message::Simple::DEBUG_FH;
local $Log::Message::Simple::MSG_FH;
local $Log::Message::Simple::ERROR_FH;
local $Log::Message::Simple::DEBUG_FH;
local $Log::Message::Simple::MSG_FH;
local *STDERR;
local $SIG{__WARN__} = sub { };
my $ref = $Class->can( $name );
( run in 1.446 second using v1.01-cache-2.11-cpan-283623ac599 )