KiokuDB::Role::Verbosity - A role for printing diagnosis to STDERR


KiokuDB documentation Contained in the KiokuDB distribution.

Index


Code Index:

NAME

Top

KiokuDB::Role::Verbosity - A role for printing diagnosis to STDERR

SYNOPSIS

Top

    $self->v("blah blah\n"); # only printed if $self->verbose is true

DESCRIPTION

Top

This role provides the verbose attribute and a v method that you can use to emit verbose output to STDERR.


KiokuDB documentation Contained in the KiokuDB distribution.

#!/usr/bin/perl

package KiokuDB::Role::Verbosity;
use Moose::Role;

use namespace::clean -except => 'meta';

has verbose => (
    isa => "Bool",
    is  => "ro",
);

sub BUILD {
    my $self = shift;

    STDERR->autoflush(1) if $self->verbose;
}

sub v {
    my $self = shift;
    return unless $self->verbose;

    STDERR->print(@_);
}

__PACKAGE__

__END__