Log::Shiras::LogSpace - Log::Shiras Role for runtime name-spaces
use Modern::Perl; use MooseX::ShortCut::BuildInstance qw( build_class ); use Log::Shiras::LogSpace; my $test_instance = build_class( package => 'Generic', roles =>[ 'Log::Shiras::LogSpace' ], add_methods =>{ get_class_space => sub{ 'ExchangeStudent' }, i_am => sub{ my( $self )= @_; print "I identify as a: " . $self->get_all_space( 'individual' ) . "\n"; } }, ); my $Generic = $test_instance->new; my $French = $test_instance->new( log_space => 'French' ); my $Spanish = $test_instance->new( log_space => 'Spanish' ); $Generic->i_am; $French->i_am; $Spanish->i_am; ####################################################################################### # Synopsis Screen Output # 01: I identify as a: Generic::ExchangeStudent::individual # 02: I identify as a: French::ExchangeStudent::individual # 03: I identify as a: Spanish::ExchangeStudent::individual #######################################################################################
This attribute is useful to manage runtime Log::Shiras caller namespace. In the case where MyCoolPackage with Log::Shiras lines is used in more than one context then it is possible to pass a context sensitive name to the attribute log_space on intantiation of the instance and have the namespace bounds only activate the desired context of the package rather than have it report everywhere it is used. The telephone call in this case would look something like this;
package MyCoolPackage sub get_class_space{ 'MyCoolPackage' } sub my_cool_sub{ my( $self, $message ) = @_; my $phone = Log::Shiras::Telephone->new( name_space => $self->get_all_space . '::my_cool_sub', ); $phone->talk( level => 'debug', message => "Arrived at my_cool_sub with the message: $message" ); # Do something cool here! }
In this case if you used my cool package instances with the log_space set to different values then only the namespace unblocked for 'FirstInstance::MyCoolPackage::my_cool_sub' would report. See the documentation for get_all_space for details.
As a general rule it works best if the subroutine 'get_class_space' is defined in an object class file (not a role file). Each subroutine space can be identified with the $add_string passed to get_all_space.
Data passed to new when creating an instance of the consuming class. For modification of this attribute see the listed attribute methods.
Definition: This will be the base log_space element returned by get_all_space
Default the consuming package name
Range Any string, but Log::Shiras will look for '::' separators
attribute methods
get_log_space
Definition: Returns the attribute value
set_log_space( $string )
Definition: sets the attribute value
has_log_space
Definition: predicate test for the attribute
Definition: This method collects the stored 'log_space' attribute value and then joins it with the results of a method call to 'get_class_space'. The 'get_class_space' attribute should be provided somewhere else in the class. The two values are joined with '::'. It will additionally join another string argument passed as $add_string to form a complete log space stack. See synopsis.
Accepts $add_string
Returns log_space . '::' . $self->get_class_space . '::' . $add_string as each element is available.
github Spreadsheet::XLSX::Reader::LibXML/issues
1. Nothing Yet
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Moose::Role
MooseX::Types::Moose
To install Log::Shiras, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Shiras
CPAN shell
perl -MCPAN -e shell install Log::Shiras
For more information on module installation, please visit the detailed CPAN module installation guide.