Verbose
<< | Cookbook-V1 | >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
Goal
Make development and debugging of PmWiki/PmWiki-scripts easier by suppling a "log"-function, that makes it easy to output information. The level of detail in the printed information should be easy to control.
Solution
The solution is a function Verbose()
that works like printf()
,
but with an extra argument in the beginning that specifies the
verbocity level
that is needed for this message to actually be
shown. The verbocity level is stored in the global variable
$VerbocityLevel, which can be set in a configuration file, or set to
e.g. 3 by appending verbose=3
to the URI of a page.
Discussion
Download Attach:verbose.php and put it in your local/
directory. To include this script from your local configuration
file or some other script, use the following code:
@ include_once('local/verbose.php'); if(!function_exists('Verbose')) { function Verbose() {} }
This ensures that your script will work even if local/verbose.php
is not found, i.e. your script does not depend on
local/verbose.php
as long as it's ok that it doesn't output any
verbose messages.
You can define your own Verbose()
by simply creating such a
function before local/verbose.php
is included for the first
time. However, please make sure that your Verbose()
is compatible
with the default version.
See Also
History
Created 2004-01-25
Comments & Bugs
Any example for an actual application? Why not verbose.php itself, before we upload and install it? Thanks. -JCG
Contributors
Copyright
Whatever pmwiki-2.4.2 -- Last modified by {{}}?