Log-Message-Simple-0.10004075500017510000144000000000001207771625300137535ustar chrisusersLog-Message-Simple-0.10/t004075500017510000144000000000001207771625300142165ustar chrisusersLog-Message-Simple-0.10/t/02_imports.t010064400017510000144000000031111207771566300164550ustar chrisusersuse 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 ()"; Test::More::ok( !$@, "using $Class with no import" ); for my $func ( @Carp, @Msg ) { Test::More::ok( !__PACKAGE__->can( $func ), " $func not imported" ); } } ### test :STD import { package Test::B; eval "use $Class ':STD'"; Test::More::ok( !$@, "using $Class with :STD import" ); for my $func ( @Carp ) { Test::More::ok( !__PACKAGE__->can( $func ), " $func not imported" ); } for my $func ( @Msg ) { Test::More::ok( __PACKAGE__->can( $func ), " $func imported" ); } } ### test :CARP import { package Test::C; eval "use $Class ':CARP'"; Test::More::ok( !$@, "using $Class with :CARP import" ); for my $func ( @Msg ) { Test::More::ok( !__PACKAGE__->can( $func ), " $func not imported" ); } for my $func ( @Carp ) { Test::More::ok( __PACKAGE__->can( $func ), " $func imported" ); } } ### test all import { package Test::D; eval "use $Class ':ALL'"; Test::More::ok( !$@, "using $Class with :ALL import" ); for my $func ( @Carp, @Msg ) { Test::More::ok( __PACKAGE__->can( $func ), " $func imported" ); } } Log-Message-Simple-0.10/t/01_use.t010064400017510000144000000002531207771470300155510ustar chrisusersuse Test::More 'no_plan'; use strict; my $Class = 'Log::Message::Simple'; use_ok( $Class ); diag( "Testing $Class version " . $Class->VERSION ) unless $ENV{PERL_CORE}; Log-Message-Simple-0.10/t/03_functions.t010064400017510000144000000043661207771566300170060ustar chrisusersuse 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 ### so we can print to closed FH without having to worry ### 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 ); $ref->( @_ ); }; } } for my $name (@Carp, @Msg) { my $ref = $Pkg->can( $name ); ok( $ref, "Found function for '$name'" ); ### start with an empty stack? cmp_ok( scalar @{[$Class->stack]}, '==', 0, " Starting with empty stack" ); ok(!$Class->stack_as_string," Stringified stack empty" ); ### call the func... no output should appear ### eval this -- the croak/confess functions die eval { $ref->( $Text ); }; my @stack = $Class->stack; cmp_ok( scalar(@stack), '==', 1, " Text logged to stack" ); for my $re ( $Text, quotemeta '['.uc($name).']' ) { like( $Class->stack_as_string, qr/$re/, " Text as expected" ); } ### empty stack again ### ok( $Class->flush, " Stack flushed" ); cmp_ok( scalar @{[$Class->stack]}, '==', 0, " Starting with empty stack" ); ok(!$Class->stack_as_string," Stringified stack empty" ); } Log-Message-Simple-0.10/CHANGES010064400017510000144000000020441207771566400150270ustar chrisusersChanges 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 Log-Message-Simple-0.10/MANIFEST010064400017510000144000000004461207771625300151640ustar chrisusersCHANGES lib/Log/Message/Simple.pm Makefile.PL MANIFEST This list of files README t/01_use.t t/02_imports.t t/03_functions.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Log-Message-Simple-0.10/lib004075500017510000144000000000001207771625300145215ustar chrisusersLog-Message-Simple-0.10/lib/Log004075500017510000144000000000001207771625300152425ustar chrisusersLog-Message-Simple-0.10/lib/Log/Message004075500017510000144000000000001207771625300166265ustar chrisusersLog-Message-Simple-0.10/lib/Log/Message/Simple.pm010064400017510000144000000170171207771620000204670ustar chrisuserspackage 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 module. =head1 FUNCTIONS =head2 msg("message string" [,VERBOSE]) Records a message on the stack, and prints it to C (or actually C<$MSG_FH>, see the C section below), if the C option is true. The C option defaults to false. Exported by default, or using the C<:STD> tag. =head2 debug("message string" [,VERBOSE]) Records a debug message on the stack, and prints it to C (or actually C<$DEBUG_FH>, see the C section below), if the C option is true. The C option defaults to false. Exported by default, or using the C<:STD> tag. =head2 error("error string" [,VERBOSE]) Records an error on the stack, and prints it to C (or actually C<$ERROR_FH>, see the C sections below), if the C option is true. The C options defaults to true. Exported by default, or using the C<:STD> tag. =cut { 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(); Provides functionality equal to C while still logging to the stack. Exported by using the C<:CARP> tag. =head2 croak(); Provides functionality equal to C while still logging to the stack. Exported by using the C<:CARP> tag. =head2 confess(); Provides functionality equal to C while still logging to the stack. Exported by using the C<:CARP> tag. =head2 cluck(); Provides functionality equal to C 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 is implemented using C, consult its manpage for the function C 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 option is true all items are returned with C output, rather than just the message. C defaults to false. =head2 Log::Message::Simple->flush() Removes all the items from the stack and returns them. Since C is implemented using C, consult its manpage for the function C 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 ];; @ISA = 'Exporter'; @EXPORT = qw[error msg debug]; @EXPORT_OK = qw[carp cluck croak confess]; %EXPORT_TAGS = ( STD => \@EXPORT, CARP => \@EXPORT_OK, ALL => [ @EXPORT, @EXPORT_OK ], ); my $log = new Log::Message; for my $func ( @EXPORT, @EXPORT_OK ) { no strict 'refs'; ### up the carplevel for the carp emulation ### functions *$func = sub { local $Carp::CarpLevel += 2 if grep { $_ eq $func } @EXPORT_OK; my $msg = shift; $log->store( message => $msg, tag => uc $func, level => $func, extra => [@_] ); }; } sub flush { return reverse $log->flush; } sub stack { return $log->retrieve( chrono => 1 ); } sub stack_as_string { my $class = shift; my $trace = shift() ? 1 : 0; return join $/, map { '[' . $_->tag . '] [' . $_->when . '] ' . ($trace ? $_->message . ' ' . $_->longmess : $_->message); } __PACKAGE__->stack; } } =head1 GLOBAL VARIABLES =over 4 =item $ERROR_FH This is the filehandle all the messages sent to C are being printed. This defaults to C<*STDERR>. =item $MSG_FH This is the filehandle all the messages sent to C are being printed. This default to C<*STDOUT>. =item $DEBUG_FH This is the filehandle all the messages sent to C are being printed. This default to C<*STDOUT>. =item $STACKTRACE_ON_ERROR If this option is set to C, every call to C will generate a stacktrace using C. Defaults to C =back =cut BEGIN { use vars qw[ $ERROR_FH $MSG_FH $DEBUG_FH $STACKTRACE_ON_ERROR ]; local $| = 1; $ERROR_FH = \*STDERR; $MSG_FH = \*STDOUT; $DEBUG_FH = \*STDOUT; $STACKTRACE_ON_ERROR = 0; } 1; # Local variables: # c-indentation-style: bsd # c-basic-offset: 4 # indent-tabs-mode: nil # End: # vim: expandtab shiftwidth=4: Log-Message-Simple-0.10/README010064400017510000144000000022011207771566300147060ustar chrisusersThis 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 make make test make install ###################################################################### AUTHOR This module by Jos Boumans . COPYRIGHT This module is copyright (c) 2002 Jos Boumans . All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. Log-Message-Simple-0.10/Makefile.PL010064400017510000144000000036201207771470300160000ustar chrisusersuse ExtUtils::MakeMaker; use strict; 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 ', ABSTRACT => 'Simplified interface to Log::Message', @LICENSE, ); sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade. my %params=@_; my $eumm_version=$ExtUtils::MakeMaker::VERSION; $eumm_version=eval $eumm_version; die "EXTRA_META is deprecated" if exists $params{EXTRA_META}; die "License not specified" if not exists $params{LICENSE}; if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) { #EUMM 6.5502 has problems with BUILD_REQUIRES $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} }; delete $params{BUILD_REQUIRES}; } delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52; delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48; delete $params{META_MERGE} if $eumm_version < 6.46; delete $params{META_ADD} if $eumm_version < 6.46; delete $params{LICENSE} if $eumm_version < 6.31; delete $params{AUTHOR} if $] < 5.005; delete $params{ABSTRACT_FROM} if $] < 5.005; delete $params{BINARY_LOCATION} if $] < 5.005; WriteMakefile(%params); } Log-Message-Simple-0.10/META.yml010064400017510000144000000011351207771625300153000ustar chrisusers--- abstract: 'Simplified interface to Log::Message' author: - 'Jos Boumans ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Log-Message-Simple no_index: directory: - t - inc requires: Carp: 0 Log::Message: 0 Test::More: 0 if: 0 resources: repository: git://github.com/jib/log-message-simple.git version: 0.10 Log-Message-Simple-0.10/META.json010064400017510000144000000021031207771625300154440ustar chrisusers{ "abstract" : "Simplified interface to Log::Message", "author" : [ "Jos Boumans " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Log-Message-Simple", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "Log::Message" : "0", "Test::More" : "0", "if" : "0" } } }, "release_status" : "stable", "resources" : { "repository" : { "url" : "git://github.com/jib/log-message-simple.git" } }, "version" : "0.10" }