| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::Role::Verbosity; | ||||||||||
| 4 | 3 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 3 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 3 | has verbose => ( | |||||||||
| 9 | isa => "Bool", | ||||||||||
| 10 | is => "ro", | ||||||||||
| 11 | ); | ||||||||||
| 12 | |||||||||||
| 13 | sub BUILD { | ||||||||||
| 14 | 35 | ▶ | my $self = shift; | ||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||
| 15 | |||||||||||
| 16 | 35 | ▶ | STDERR->autoflush(1) if $self->verbose; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | sub v { | ||||||||||
| 20 | 53 | ▶ | my $self = shift; | ||||||||
|
Subroutine
v: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||
| 21 | 53 | ▶ | return unless $self->verbose; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | |||||||||||
| 23 | 0 | STDERR->print(@_); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 3 | __PACKAGE__ | |||||||||
| 27 | |||||||||||
| 28 | __END__ | ||||||||||
| 29 | |||||||||||
| 30 | =pod | ||||||||||
| 31 | |||||||||||
| 32 | =head1 NAME | ||||||||||
| 33 | |||||||||||
| 34 | KiokuDB::Role::Verbosity - A role for printing diagnosis to STDERR | ||||||||||
| 35 | |||||||||||
| 36 | =head1 SYNOPSIS | ||||||||||
| 37 | |||||||||||
| 38 | $self->v("blah blah\n"); # only printed if $self->verbose is true | ||||||||||
| 39 | |||||||||||
| 40 | =head1 DESCRIPTION | ||||||||||
| 41 | |||||||||||
| 42 | This role provides the C<verbose> attribute and a C<v> method that you can use | ||||||||||
| 43 | to emit verbose output to C<STDERR>. | ||||||||||