Log-Shiras

 view release on metacpan or  search on metacpan

lib/Log/Shiras/Telephone.pm  view on Meta::CPAN

	###InternalTelephonE		message	=> [ "Message reported |$report_count| times" ], } );

	# Handle fail_over
	if( $report_count < 1 and ( $data_ref->{fail_over} or $self->should_fail_over) ){
		###InternalTelephonE	$switchboard->master_talk( { report => 'log_file', level => 4,
		###InternalTelephonE		name_space => 'Log::Shiras::Telephone::talk',
		###InternalTelephonE		message	=> [ "Message allowed but found no destination!", $data_ref->{message} ], } );
		warn longmess( "This message sent to the report -$data_ref->{report}- was approved but found no destination objects to use" ) if !$ENV{hide_warn};
		print STDOUT join( "\n\t", @{$data_ref->{message}} ) . "\n";
	}

	# Return the result
	return $report_count;
}

#########1 Private Attributes 3#########4#########5#########6#########7#########8#########9



#########1 Private Methods    3#########4#########5#########6#########7#########8#########9



#########1 Phinish            3#########4#########5#########6#########7#########8#########9

no Moose;
__PACKAGE__->meta->make_immutable;

1;

#########1 Documentation      3#########4#########5#########6#########7#########8#########9
__END__

=head1 NAME

Log::Shiras::Telephone - Send messages with Log::Shiras

=head1 SYNOPSIS

	package MyCoolPackage;
	use Moose;
	use lib 'lib', '../lib',;
	use Log::Shiras::Telephone;

	sub make_a_noise{
		my( $self, $message ) = @_;
		my $phone = Log::Shiras::Telephone->new(
						name_space => 'TellMeAbout::make_a_noise',
						fail_over => 1,
						report => 'spy',
					);
		$phone->talk( level => 'debug',
			message => "Arrived at make_a_noise with the message: $message" );
		print '!!!!!!!! ' . uc( $message  ) . " !!!!!!!!!\n";
		$phone->talk( level => 'info',
			message => "Finished printing message" );
	}

	package main;

	use Modern::Perl;
	use Log::Shiras::Switchboard;
	use Log::Shiras::Report::Stdout;
	use MyCoolPackage;
	$| = 1;
	my	$agitation = MyCoolPackage->new;
		$agitation->make_a_noise( 'Hello World 1' );#
	my	$operator = Log::Shiras::Switchboard->get_operator(
			name_space_bounds =>{
				TellMeAbout =>{
					make_a_noise =>{
						UNBLOCK =>{
							# UNBLOCKing the report (destinations)
							# 	at the 'TellMeAbout::make_a_noise' caller name_space and deeper
							spy	=> 'info',# for info and more urgent messages
						},
					},
				},
			},
		);
		$agitation->make_a_noise( 'Hello World 2' );#
		$operator->add_reports(
			spy =>[ Print::Log->new, ],
		);
		$agitation->make_a_noise( 'Hello World 3' );#

	#######################################################################################
	# Synopsis Screen Output
	# 01: !!!!!!!! HELLO WORLD 1 !!!!!!!!!
	# 02: !!!!!!!! HELLO WORLD 2 !!!!!!!!!
	# 03: This message sent to the report -spy- was approved but found no destination objects to use at log_shiras_telephone.pl line 16, <DATA> line 1.
	# 04: 	MyCoolPackage::make_a_noise(MyCoolPackage=HASH(0x58df970), "Hello World 2") called at log_shiras_telephone.pl line 67
	# 05: Finished printing message
	# 06: !!!!!!!! HELLO WORLD 3 !!!!!!!!!
	# 07: | level - info   | name_space - TellMeAbout::make_a_noise
	# 08: | line  - 0016   | file_name  - log_shiras_telephone.pl
	# 09: 	:(	Finished printing message ):
	#######################################################################################

=head2 SYNOPSIS EXPLANATION

=head3 Output explanation

01: This is the result of

	$agitation->make_a_noise( 'Hello World 1' );

Where the output is processed by the make_a_noise method of the package MyCoolPackage

02: Same as line 01

03-05: The switchboard actually turned on permissions for some logging from MyCoolPackage
prior to the output from line 02 but there was no report destination available so the
'fail_over' attribute kicked in and printed the message out with a warning.

06: Same as line 01

07-09: This time before the output for line 06 was sent an actual report object was
registered in the switchboard against the 'spy' report name that MyCoolPackage was
sending logging messages to.  These lines are the result of that report object
L<Log::Shiras::Report::Stdout> with the note that line 09: and line 05: have the same



( run in 0.700 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )