Cookbook
Topics |
Debug MessagesSummary: A
function dmsg() for use in debugging PmWiki recipesVersion: 2024-04-30
Prerequisites: PmWiki 2.3.33; PHP 8
Status: In use
Maintainer: skiwi
Categories: Markup PmWiki Developer
Discussion: DebugMessages-Talk
Questions answered by this recipeWhen I am writing a PmWiki recipe how can I quickly and easily log debug information from the recipe? DescriptionThis recipe provides a simple The recipe provides a function $smsgprefix : the prefix to the debug output line or block
$smsgdata : the data, of any type, to be dumped in human friendly format
$smshtml : optional boolean value for when $smsgdata contains preformatted HTML to be passed through
$dmsgId : optional string value used as message identifier
This recipe is inspired by the code snippet in Cookbook:Debugging For Cookbook Authors, and provides an enhanced, tried and tested, reusable version of this. Installation
UsageThe recipe provides a page variable You can then use Messages Replacement A drop in replacement for the PmWiki (:messages:) directive to display the messages. ConfigurationIn the recipe that is using if (!function_exists('dmsg')) { if (!isset ($MessagesFmt['functionName'])) $MessagesFmt['functionName'] = []; # initialise function dmsg (string $smsgprefix, $smsgdata) { # local instance global $MessagesFmt; $MessagesFmt['functionName'] [] = $smsgprefix . '= ' . (is_array ($smsgdata) ? @implode (BR . $smsgprefix . '= ', \PHSC ($smsgdata)) : \PHSC ($smsgdata)); } # end function } # end ifreplacing " functionName " with a unique identifier of your choosing.
This will ensure that whether or not the The recipe will use the parameter
Change log / Release notes2024-04-30 Update for PHP 8 warnings 2024-01-14 Initial version See alsoOn PmWikiFrom the PmWiki developer category:
ContributorsSpecial thanks to Petko and the PmWiki documenters. TalkbackSee discussion at DebugMessages-Talk |
tahi Page last modified on 2024 Apr 28 08:16
Edit - History - Recent Changes - WikiHelp - Search - email page as link -> mailto:?Subject="KiwiWiki: Debug Messages"&Body=