Test::S...LogMixin(3)

πŸ“¦
version 1.84 Β· 2 versions
, in fedora 43

πŸ’– Test::S...LogMixin(3) πŸ’–

okay bestie, gather round, because this one is two packages in one trench coat and both of them are lowkey serving. it's straight out of the User Contributed Perl Documentation, it's a perl manpage, and we're doing this together, no cap. 🫢✨


✨ NAME ✨

Test::Smoke::LogMixin β€” a "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 πŸ’…

so picture this: this package, with all of its mixin-methods, is basically acting like a role β€” it extends your traditional (like, created with bless()) object with 4 new methods. not 3, not 5. four. slay. πŸ’–

it's also carrying around some extra Test::Smoke::App::Base logic to figure out the log-level (by looking at $app->option('verbose')). and for other object types? it tries to fiend if there are methods by the name "verbose" or "v", or maybe the keys "_verbose" or "_v" (See also Test::Smoke::ObjectBase). detective behavior honestly. πŸ”

and the tea on the three log methods: they use the sprintf() way of composing strings whenever more than 1 argument is passed! periodt. πŸ’…

🌸 $app->verbosity 🌸

Return the verbosity of this app. iconic, no notes.

Arguments

None. she's low maintenance. πŸŽ€

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.


okay bestie, quick vibe check β€” that was package number one. now we're switching gears, because the same page also documents a whole other little helper. keep scrolling. πŸ¦‹

πŸ’– 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. your very own little logger baby. 🍼

Arguments

Named, hash:

  • v => <0|1|2>

Returns

The Test::Smoke::Logger instance.


(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:

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.


and that's the whole page, bestie!! πŸ₯³ this one shipped with perl v5.42.0 and the date on it is 2025-07-25 β€” so like, remember that vintage when you cite it. now go forth and log responsibly, my main character. πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from