Skip to content

Debugging and Logging

Q edited this page Aug 17, 2020 · 9 revisions

The WP_Debug constant must be set to true in the wp_config.php application in order to write to the log file and the Willow plugin static property $debug OR an external debug control must be set to true + debugging is controlled either on a context, context + task level or directly via template config->debug = true setting

Willow has its own dedicated debug file, called willow.log, which is located in the root or the wp-contents directory.

Enable Global Debugging

Willow load a global context file, located at library/view/context/global.php - this includes top level settings, as follows:

// return an array ##
return [ 'global' 			=> [

	'config'				=> [
		
		// run ALL contexts ##
		'run' 				=> true,
		
		// ALL context debugging ##
		'debug'				=> false,

		// return strategy
		'return'       	 	        => 'echo'

	],

]];

As this file is located in the Q Willow plugin, it is not advised to change this directly, instead create a matching file in your own WP Theme and place it is the same logical position - that is library/view/context/global.php from the root folder of the active parent or child theme - there is no need to include this file directly, Willow should find it.

This is also possible from a plugin, if it has been registered correctly with Willow - Read more

Enable Context Debugging

As with global configuration, each context can also have a configuration file to define context level settings, this can be placed in the same location as the global.js, but named according to the context - some examples are:

  • ui.php control how ui context->tasks behave
  • post.php define settings for post tasks
  • extension~search.php control settings for a specific task within the extension context

In theory, all configuration could sit with one single, large, configuration file, but this quickly becomes unmanageable and less portable - so Willow both allows and encourages the creation of global, context and context+task specific files.

Within any of the configuration files listed above we can place any or all of the configuration options from global.php, re-defining the settings we need at a more granular level.

Note the naming convention of the files follows exactly the template usage - see this example:

{~ extension~search ~} would load it's configuration from extension~search.php - with all the logic of fallbacks, priority and configuration merging taken into account.

Enable Debugging per Willow

In the following example, we are enabling debugging for the called Willow:

{~ group~frontpage_work{+ [a] 
	config = debug: true & 
	config->post = {% [r] get_site_option{+ page_on_front +} %} 
+} ~}

The result of this configuration setting will be to include a new key frontpage_work in the debug output, which will include all recorded events in the processing of the function data and output.

Notes:

  • Many aspects of how the debugging process works can be controlled via filters, from the file location to the default log keys to include - in order to understand better how this works, please via the code
Clone this wiki locally