Puppet::Log - Log facility with an optional Tk display
use Puppet::Log ; my $log = new Puppet::Log('title' =>'log test') ; $log -> log("Some text") ; # $wmgr can be a toplevel Tk main window or a Tk::Multi::Manager $log ->display($wmgr, 1) ;
This class implements a log facility with an optional Tk display.
I.e once the class is created, you can log messages in it, but the Tk display does no need to be created at the same time. You may invoke later only when you need it.
When the Tk display is not invoked, the log can be either printed on STDOUT or warned on STDERR (or stay hidden). But in any case, the log message will be stored in the class so that all log messages can be retrieved later by the user or by the Tk display when invoked.
Once the Tk display is invoked, it will be updated by new logs.
Creates the log object.
The constructor parameters are :
Will log the passed text
Optional parameters are:
Clear all stored logs.
Return an array made of all stored logs.
Will create the log display. The log display is in fact a Tk::Multi::Text window which can managed by a Tk::Multi::Manager object.
The parent window object.
The Tk::Multi::Manager reference
When hidden is 1, the log will not displayed on start-up. (default is to show the log window)
If you don't provide a multi_manager reference, Puppet::Log will consider that you want the Log to appear in its own TopLevel window.
In this case Puppet::Log will create a new Toplevel window and create a Tk::Multi::Manager in it. In this case, it will feature a File->close menu entry to destroy the Log window.
Once the Log window is destroyed, the display method can then be called later to recreate it.
In any case display() returns the manager reference. You may reuse this reference to add another Log display in the Toplevel window that Log just created. So that both log windows are displayed in the same Tk window. (See the t/top_log.t example to see what I mean)
Will raise the log window. Note that this function is ignored if its called before display().
Puppet classes are a set of utility classes which can be used by any object. If you use directly the Puppet::*Body class, you get the plain functionnality. And if you use the Puppet::* class, you can get the same functionnality and a Tk Gui to manage it.
The basic idea is when you construct a Puppet::* object, you have all the functionnality of the object without the GUI. Then, when the need arises, you may (or the class may decide to) open the GUI of the object. On the other hand, if the need does not arise, you may create a lot of objects without cluttering your display.
Dominique Dumont, Dominique_Dumont@grenoble.hp.com
Copyright (c) 1998-1999,2006 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.