-
-
30 Mar 2022 09:25:47 UTC
- Distribution: Test-Smoke
- Module version: 0.002
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (24)
- Testers (221 / 5 / 0)
- Kwalitee
Bus factor: 2- 65.73% Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (358.2KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- CGI::Util
- Capture::Tiny
- File::Spec
- HTTP::Tiny
- JSON::XS
- POSIX
- System::Info
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Test::Smoke::LogMixin - "Role" that adds logging methods to "traditional" objects.
SYNOPSIS
package MyPackage; use warnings; use strict; use Test::Smoke::LogMixin; sub new { my $class = shift; my %selfish = @_; $selfish{_verbose} ||= 0; return bless \%selfish, $class; } 1; package main; use MyPackage; my $o = MyPackage->new(_verbose => 2); $o->log_debug("This will end up in the log");
DESCRIPTION
This package with these mixin-methods acts like a role to extend your traditional (created with
bless()
) object with 4 new methods. It has some extra Test::Smoke::App::Base logic to determine the log-level (by looking at$app->option('verbose')
). For other object types it tries to fiend if there are methods by the nameverbose
orv
, or maybe the keys_verbose
or_v
(See also Test::Smoke::ObjectBase).The three log methods use the
sprintf()
way of composing strings whenever more than 1 argument is passed!$app->verbosity
Return the verbosity of this app.
Arguments
None.
Returns
The value of either
_verbose
or_v
$app->log_warn($fmt, @values)
prinf $fmt, @values
to the currently selected filehandle.Arguments
Positional.
- $fmt => a (s)printf format
-
The format gets an extra new line if one wasn't present.
- @values => optional vaules for the template.
Returns
use in void context.
Exceptions
None.
$app->log_info($fmt, @values)
prinf $fmt, @values
to the currently selected filehandle if the 'verbose' option is set.Arguments
Positional.
- $fmt => a (s)printf format
-
The format gets an extra new line if one wasn't present.
- @values => optional vaules for the template.
Returns
use in void context.
Exceptions
None.
$app->log_debug($fmt, @values)
prinf $fmt, @values
to the currently selected filehandle if the 'verbose' option is set to a value > 1.Arguments
Positional.
- $fmt => a (s)printf format
-
The format gets an extra new line if one wasn't present.
- @values => optional vaules for the template.
Returns
use in void context.
Exceptions
None.
NAME
Test::Smoke::Logger - Helper object for logging.
SYNOPSIS
use Test::Smoke::LogMixin; my $logger = Test::Smoke::Logger->new(v => 1); $logger->log_warn("Minimal log level"); # v >= 0 $logger->log_info("Medium log level"); # v <= 1 $logger->log_debug("High log level"); # v > 1
DESCRIPTION
Test::Smoke::Logger->new(%arguments)
Return a logger instance.
Arguments
Named, hash:
Returns
The Test::Smoke::Logger instance.
COPYRIGHT
(c) 2020, All rights reserved.
* Abe Timmerman <abeltje@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See:
* <http://www.perl.com/perl/misc/Artistic.html>, * <http://www.gnu.org/copyleft/gpl.html>
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Module Install Instructions
To install Test::Smoke, copy and paste the appropriate command in to your terminal.
cpanm Test::Smoke
perl -MCPAN -e shell install Test::Smoke
For more information on module installation, please visit the detailed CPAN module installation guide.