Extensions
Topics |
Diagnostic Messages
Summary: A
function dmsg() for use in diagnosing PmWiki entensions and recipesVersion: 2024-08-18
Prerequisites: PmWiki 2.3.36; PHP 8.3; ExtensionHub
Status: In use
Maintainer: skiwi
Discussion: DiagnosticMessages-Talk
Questions answered by this extensionWhen I am writing a PmWiki extension or recipe how can I quickly and easily log diagnostic information from the extension? DescriptionThis extension provides a simple The extension provides a function $smsgprefix : the prefix to the diagnostic output line or block
$smsgdata : the data, of any type, to be dumped in human friendly format
$smshtml : an optional boolean value for when $smsgdata contains preformatted HTML to be passed through
$dmsgId : an optional string value used as message identifier
$dmsgLog : optional, if true additionally writes the message to the PHP error log
This extension 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 extension provides a page variable You can then use Messages Replacement Redirects to Extensions.MessagesReplacement to display the messages. ConfigurationIn the extension or 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 extension will use the parameter
Change log / Release notes2024-08-18 convert to an extension 2024-04-30 Update for PHP 8 warnings 2024-01-14 Initial version See also
On PmWikiFrom the PmWiki developer category:
ContributorsSpecial thanks to Petko and the PmWiki documenters. TalkbackSee discussion at DiagnosticMessages-Talk |
tahi Page last modified on 2024 Sept 14 17:17
Edit - History - Recent Changes - WikiHelp - Search - email page as link -> mailto:?Subject="KiwiWiki: Diagnostic Messages"&Body=