Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#813677
hi all,
for the library see :viewtopic.php?f=44&t=730353
for error management : http://wiki.processmaker.com/3.0/Trigge ... Management
Visual Studio Code as external Editor : viewtopic.php?f=47&t=730343

I often want to check api return or sql result, so i write the result to a log file.
I made a function in my PHPLibrary and i am able to call it from my trigger.
I can then read the log result in the file /ex /opt/processmaker/shared/log/exceptions_log.log

in your lib :
Code: Select all
/**
 * log function
 * @param $log 	log what ?? use var_export(something, true) for complex variables
*/
function wlog($log){
	$logFilePath = PATH_DATA . 'log' . PATH_SEP . 'exceptions_log.log';
	$content = "\n\n".getCurrentTime()." : ".$log;
	file_put_contents($logFilePath, $content, FILE_APPEND);
}
PATH_ DATA & PATH_SEP are ProcessMaker constant and system dependant /linux ex : PATH_DATA="/opt/processmaker/shared", PATH_SEP="/"

in your trigger :
Code: Select all
require_once("/opt/PMPHPLib/PHPPMLib.php");
define(DEBUG, false); 
$app=@@APPLICATION;
$process="THE NAME OF YOUR PROCESS";
$trigger="THE NAME OF THE TRIGGER";
(DEBUG) ? wlog("[proc:$process][Trigg:$trigger] : START $app ") : null;

(DEBUG) ? wlog("[proc:$process][Trigg:$trigger] var :\n\t".var_export($var ,true)) : null;
Since i can use snippet in visual studio code i use this a lot.

snippet code:
Code: Select all
"wlog":{
		"prefix": "wlog",
		"body": [
			"(DEBUG) ? wlog(\"[proc:$$process][Trigg:$$trigger] ${1:var} :\\n\\t\".var_export($${1:var} ,true)) : null;",
			"$2"
		],
		"description": "Log output to exceptions.log"
	}

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]