Log-Shiras
view release on metacpan or search on metacpan
lib/Log/Shiras/Switchboard.pm view on Meta::CPAN
=head3 get_log_levels( $report_name )
=over
B<Definition:> This will return the L<log level names|/logging_levels> names for a given
report name in an array ref. If no custom levels are defined it will return the default
level list.
B<Accepts:> a report name
B<Returns:> an array ref of the defined log levels for that report.
=back
=head3 send_buffer_to_output( $report_name )
=over
B<Definition:> This will flush the contents of the $report_name L<buffer|/buffering>
to all the associated report objects.
B<Accepts:> a $report_name
B<Returns:> The number of times that $report_object->add_line( $message_ref ) was called to
complete the buffer flush.
=back
=head3 start_buffering( $report_name )
=over
B<Definition:> This will start L<buffering|/buffering> for the $report_name. If the buffering is
already implemented then nothing new happens. No equivalent report or name_space_bounds
are required to turn buffering on!
B<Accepts:> a $report_name string
B<Returns:> 1
=back
=head3 clear_buffer( $report_name )
=over
B<Definition:> This will remove all messages currently in the L<buffer|/buffering>
without sending them to the report.
B<Accepts:> a $report_name string
B<Returns:> 1
=back
=head1 SYNOPSIS
This is pretty long so I put it at the end
#!perl
use Modern::Perl;
use lib 'lib', '../lib',;
use Log::Shiras::Unhide qw( :debug :InternalSwitchboarD );#
use Log::Shiras::Switchboard;
###InternalSwitchboarD use Log::Shiras::Report::Stdout;
$| = 1;
###LogSD warn "lets get ready to rumble...";
my $operator = Log::Shiras::Switchboard->get_operator(
name_space_bounds =>{
main =>{
UNBLOCK =>{
# UNBLOCKing the quiet, loud, and run reports (destinations)
# at the 'main' caller name_space and deeper
quiet => 'warn',
loud => 'info',
run => 'trace',
},
},
Log =>{
Shiras =>{
###InternalSwitchboarD Switchboard =>{#<-- Internal reporting enabled here
###InternalSwitchboarD get_operator =>{
###InternalSwitchboarD UNBLOCK =>{
###InternalSwitchboarD # UNBLOCKing log_file
###InternalSwitchboarD # at Log::Shiras::Switchboard::get_operator
###InternalSwitchboarD # (self reporting)
###InternalSwitchboarD log_file => 'info',
###InternalSwitchboarD },
###InternalSwitchboarD },
###InternalSwitchboarD master_talk =>{
###InternalSwitchboarD _buffer_decision =>{
###InternalSwitchboarD UNBLOCK =>{
###InternalSwitchboarD # UNBLOCKing log_file
###InternalSwitchboarD # at Log::Shiras::Switchboard::master_talk::_buffer_decision
###InternalSwitchboarD # (self reporting)
###InternalSwitchboarD log_file => 'trace',
###InternalSwitchboarD },
###InternalSwitchboarD },
###InternalSwitchboarD },
###InternalSwitchboarD send_buffer_to_output =>{
###InternalSwitchboarD UNBLOCK =>{
###InternalSwitchboarD # UNBLOCKing log_file
###InternalSwitchboarD # at Log::Shiras::Switchboard::_flush_buffer
###InternalSwitchboarD # (self reporting)
###InternalSwitchboarD log_file => 'info',
###InternalSwitchboarD },
###InternalSwitchboarD },
###InternalSwitchboarD },#<-- Internal reporting enabled through here
},
},
},
reports =>{
quiet =>[
Print::Wisper->new,
],
loud =>[
{
package => 'Print::Excited',
add_methods =>{
add_line => sub{
shift;
( run in 0.514 second using v1.01-cache-2.11-cpan-d7f47b0818f )