Agent-TCLI
view release on metacpan or search on metacpan
lib/Agent/TCLI/Base.pm view on Meta::CPAN
package Agent::TCLI::Base;
#
# $Id: Base.pm 59 2007-04-30 11:24:24Z hacker $
#
=head1 NAME
Agent::TCLI::Base - Base object for other TCLI objects
=head1 SYNOPSIS
Base object. Not for direct use.
=head1 DESCRIPTION
Base object. Not for direct use.
=cut
use warnings;
use strict;
use Carp;
our $VERSION = '0.030.'.sprintf "%04d", (qw($Id: Base.pm 59 2007-04-30 11:24:24Z hacker $))[2];
use Object::InsideOut;
use Data::Dump qw(pp);
=head2 ATTRIBUTES
The following attributes are accessible through standard accessor/mutator
methods and may be set as a parameter to new unless otherwise noted.
=over
=cut
# Standard class utils
# I need to redo err handling as its not useful as is.
=item err
Error message if something went wrong with a method call. Cannot be set or
passed in with new. Not actually used, as erroring needs to be revisited.
=cut
my @err :Field
:Get('err');
=item verbose
Turns on/off internal state messages and warnings. Higher values produce more
verbosity.
=cut
# TODO change verbose to verbosity
my @verbose :Field
:Arg('Name' => 'verbose', 'Default' => 0 )
:Acc('verbose');
=item do_verbose
A routine to output the results of a verbose call.
This allows it to be changed within an object.
B<do_verbose> will only accept code type values.
=cut
my @do_verbose :Field
:Arg('Name' => 'do_verbose', 'Default' => sub { print (@_) } )
:Acc('do_verbose')
:Type('CODE');
sub _set_err {
my ($self, $args) = @_;
$self->set(\@err, $args);
$self->Verbose("Err called");
return undef;
}
=back
=head2 METHODS
=over
=item Verbose (<message>, [ <level>, <dump_var> ] )
This method is use to output all logging and debugging commands. It will use
the sub in do_verbose to output the message if the level is less than or
equal to the current value of $self->verbose. If level is not suppiled,
it defaults to one.
If a dump_var is included, its value will be output using the Data::Dump::pp
function. This can pe useful for checking the inside of array, hashes
and objects. If the object is an OIO object, use the objects own $obj->dump(1)
method in the message.
=cut
sub Verbose {
my ($self, $message, $level, $var) = @_;
$level = 1 unless defined($level);
# Support Verbose in init before default is set:
( run in 0.686 second using v1.01-cache-2.11-cpan-2398b32b56e )