Log::Dispatch::ToTk - Class to redirect Log::Dispatch to Tk widgets
# Log::Dispatch::ToTk must be used in a composite widget Tk::Widget->Construct('LogText'); sub InitObject { my ($dw,$args) = @_ ; # retrieve parameters specific to Log::Dispatch::* my %params ; foreach my $key (qw/name min_level max_level/) { $params{$key} = delete $args->{$key} if defined $args->{$key}; } # create the TkTk buddy class $dw->{logger} = Log::Dispatch::ToTk-> new(%params, widget => $dw) ; # initiaze the widget $dw->SUPER::InitObject($args) ; } # mandatory method in Tk widget using Log::Dispatch::ToTk sub logger { my $dw = shift; return $dw->{logger} ; }
__END__
Most users will only need to use Log::Dispatch::TkText widget to have Log::Dispatch messages written on a text widget.
For more fancy uses, this module can be used by a composite widget dedicated to handle Log::Dispatch logs.
This module is the interface class between Log::Dispatch and Tk widgets. This class is derived from Log::Dispatch::Output.
One ToTk object will be created for each Log::Dispatch::Tk* widget and the user must register the ToTk object to the log dispatcher.
Create a new ToTk object. Parameter are :
widget ($)
The buddy widget object
name ($)
The name of the object (not the filename!). Required.
min_level ($)
The minimum logging level this object will accept. See the Log::Dispatch documentation for more information. Required.
max_level ($)
The maximum logging level this obejct will accept. See the Log::Dispatch documentation for more information. This is not required. By default the maximum is the highest possible level (which means functionally that the object has no maximum).
Sends a message if the level is greater than or equal to the object's minimum level.
Dominique Dumont <ddumont@cpan.org> using Log::Dispatch and Log::Dispatch::Output from Dave Rolsky, autarch@urth.org
Copyright (c) 2000, 2003, 2017 Dominique Dumont This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Log::Dispatch, Log::Dispatch::Email, Log::Dispatch::Email::MailSend, Log::Dispatch::Email::MailSendmail, Log::Dispatch::Email::MIMELite, Log::Dispatch::File, Log::Dispatch::Handle, Log::Dispatch::Screen, Log::Dispatch::Syslog, Log::Dispatch::TkText
To install Log::Dispatch::ToTk, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Dispatch::ToTk
CPAN shell
perl -MCPAN -e shell install Log::Dispatch::ToTk
For more information on module installation, please visit the detailed CPAN module installation guide.