diff options
author | 2014-03-24 14:58:42 +0000 | |
---|---|---|
committer | 2014-03-24 14:58:42 +0000 | |
commit | 91f110e064cd7c194e59e019b83bb7496c1c84d4 (patch) | |
tree | 3e8e577405dba7e94b43cbf21c22f21aaa5ab949 /gnu/usr.bin/perl/cpan/Log-Message-Simple | |
parent | do not call purge_task every 10 secs, it is only needed once at startup and (diff) | |
download | wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.tar.xz wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.zip |
Import perl-5.18.2
OK espie@ sthen@ deraadt@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Log-Message-Simple')
3 files changed, 42 insertions, 41 deletions
diff --git a/gnu/usr.bin/perl/cpan/Log-Message-Simple/lib/Log/Message/Simple.pm b/gnu/usr.bin/perl/cpan/Log-Message-Simple/lib/Log/Message/Simple.pm index efceae5b676..f9db4ffc1aa 100644 --- a/gnu/usr.bin/perl/cpan/Log-Message-Simple/lib/Log/Message/Simple.pm +++ b/gnu/usr.bin/perl/cpan/Log-Message-Simple/lib/Log/Message/Simple.pm @@ -1,13 +1,14 @@ package Log::Message::Simple; +use if $] > 5.017, 'deprecate'; use strict; use Log::Message private => 0;; -BEGIN { - use vars qw[$VERSION]; - $VERSION = 0.08; +BEGIN { + use vars qw[$VERSION]; + $VERSION = '0.10'; } - + =pod @@ -45,7 +46,7 @@ Log::Message::Simple - Simplified interface to Log::Message 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 @@ -68,7 +69,7 @@ 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<STDOUT> (or -actually C<$DEBUG_FH>, see the C<GLOBAL VARIABLES> section below), +actually C<$DEBUG_FH>, see the C<GLOBAL VARIABLES> section below), if the C<VERBOSE> option is true. The C<VERBOSE> option defaults to false. @@ -83,10 +84,10 @@ The C<VERBOSE> options defaults to true. Exported by default, or using the C<:STD> tag. -=cut +=cut { package Log::Message::Handlers; - + sub msg { my $self = shift; my $verbose = shift || 0; @@ -127,8 +128,8 @@ Exported by default, or using the C<:STD> tag. my $msg = '['. $self->tag . '] ' . $self->message; - print $Log::Message::Simple::STACKTRACE_ON_ERROR - ? Carp::shortmess($msg) + print $Log::Message::Simple::STACKTRACE_ON_ERROR + ? Carp::shortmess($msg) : $msg . "\n"; select $old_fh; @@ -197,23 +198,23 @@ BEGIN { @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, @@ -265,7 +266,7 @@ printed. This default to C<*STDOUT>. =item $STACKTRACE_ON_ERROR -If this option is set to C<true>, every call to C<error()> will +If this option is set to C<true>, every call to C<error()> will generate a stacktrace using C<Carp::shortmess()>. Defaults to C<false> @@ -280,7 +281,7 @@ BEGIN { $ERROR_FH = \*STDERR; $MSG_FH = \*STDOUT; $DEBUG_FH = \*STDOUT; - + $STACKTRACE_ON_ERROR = 0; } diff --git a/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/02_imports.t b/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/02_imports.t index 4910b971c90..4fc22ba4ecf 100755 --- a/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/02_imports.t +++ b/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/02_imports.t @@ -9,50 +9,50 @@ 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 @@ -60,9 +60,9 @@ my @Msg = qw[msg debug error]; 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" ); - } -} + } +} diff --git a/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/03_functions.t b/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/03_functions.t index 7d8a0d89949..952efb9aae8 100755 --- a/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/03_functions.t +++ b/gnu/usr.bin/perl/cpan/Log-Message-Simple/t/03_functions.t @@ -18,7 +18,7 @@ use_ok( $Class ); ### & friends will print there for my $name (@Carp, @Msg) { no strict 'refs'; - *$name = sub { + *$name = sub { local $^W; ### do the block twice to avoid 'used only once' @@ -36,41 +36,41 @@ use_ok( $Class ); 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" ); - + 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).']' ) { + + for my $re ( $Text, quotemeta '['.uc($name).']' ) { like( $Class->stack_as_string, qr/$re/, " Text as expected" ); } - ### empty stack again ### + ### 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" ); + ok(!$Class->stack_as_string," Stringified stack empty" ); } |