PMCORE-546
This commit is contained in:
@@ -6075,6 +6075,7 @@ class G
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add log of execution of triggers
|
* Add log of execution of triggers
|
||||||
|
*
|
||||||
* @param $data
|
* @param $data
|
||||||
* @param string $error
|
* @param string $error
|
||||||
* @param string $typeError
|
* @param string $typeError
|
||||||
@@ -6082,24 +6083,22 @@ class G
|
|||||||
*/
|
*/
|
||||||
public static function logTriggerExecution($data, $error = 'NO-ERROR', $typeError = '', $executionTime = 0)
|
public static function logTriggerExecution($data, $error = 'NO-ERROR', $typeError = '', $executionTime = 0)
|
||||||
{
|
{
|
||||||
if ((!empty($data['_CODE_']) || $typeError == 'FATAL_ERROR') && isset($data['_DATA_TRIGGER_']) &&
|
if ((!empty($data['_CODE_']) || $typeError == 'FATAL_ERROR') && empty($data['_DATA_TRIGGER_']['_TRI_LOG_'])) {
|
||||||
!isset($data['_DATA_TRIGGER_']['_TRI_LOG_'])
|
|
||||||
) {
|
|
||||||
$lg = Bootstrap::getDefaultContextLog();
|
$lg = Bootstrap::getDefaultContextLog();
|
||||||
$lg['TRI_TITLE'] = isset($data['_DATA_TRIGGER_']['TRI_TITLE']) ? $data['_DATA_TRIGGER_']['TRI_TITLE'] : '';
|
$lg['triTitle'] = isset($data['_DATA_TRIGGER_']['TRI_TITLE']) ? $data['_DATA_TRIGGER_']['TRI_TITLE'] : '';
|
||||||
$lg['TRI_UID'] = isset($data['_DATA_TRIGGER_']['TRI_UID']) ? $data['_DATA_TRIGGER_']['TRI_UID'] : '';
|
$lg['triUid'] = isset($data['_DATA_TRIGGER_']['TRI_UID']) ? $data['_DATA_TRIGGER_']['TRI_UID'] : '';
|
||||||
$lg['TRI_CODE'] = isset($data['_DATA_TRIGGER_']['TRI_WEBBOT']) ? $data['_DATA_TRIGGER_']['TRI_WEBBOT'] : '';
|
$lg['triCode'] = isset($data['_DATA_TRIGGER_']['TRI_WEBBOT']) ? $data['_DATA_TRIGGER_']['TRI_WEBBOT'] : '';
|
||||||
$lg['TRI_EXECUTION_TIME'] = $executionTime;
|
$lg['triExecutionTime'] = $executionTime;
|
||||||
$lg['TRI_MSG_ERROR'] = $error;
|
$lg['triMessageError'] = $error;
|
||||||
$lg['APP_UID'] = isset($data['APPLICATION']) ? $data['APPLICATION'] : '';
|
$lg['appUid'] = isset($data['APPLICATION']) ? $data['APPLICATION'] : '';
|
||||||
$lg['PRO_UID'] = isset($data['PROCESS']) ? $data['PROCESS'] : '';
|
$lg['proUid'] = isset($data['PROCESS']) ? $data['PROCESS'] : '';
|
||||||
$lg['TAS_UID'] = isset($data['TASK']) ? $data['TASK'] : '';
|
$lg['tasUid'] = isset($data['TASK']) ? $data['TASK'] : '';
|
||||||
$lg['USR_UID'] = isset($data['USER_LOGGED']) ? $data['USER_LOGGED'] : '';
|
$lg['usrUid'] = isset($data['USER_LOGGED']) ? $data['USER_LOGGED'] : '';
|
||||||
|
|
||||||
Bootstrap::registerMonolog(
|
Bootstrap::registerMonolog(
|
||||||
(empty($sError)) ? 'TriggerExecution' : 'TriggerExecutionError',
|
(empty($error)) ? 'TriggerExecution' : 'TriggerExecutionError',
|
||||||
(empty($sError)) ? 200 : 400,
|
(empty($error)) ? 200 : 400,
|
||||||
(empty($sError)) ? 'Trigger Execution' : 'Trigger Execution Error',
|
(empty($error)) ? 'Trigger Execution' : 'Trigger Execution Error',
|
||||||
$lg,
|
$lg,
|
||||||
$lg['workspace'],
|
$lg['workspace'],
|
||||||
'processmaker.log'
|
'processmaker.log'
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
namespace Tests\unit\gulliver\system;
|
namespace Tests\unit\gulliver\system;
|
||||||
|
|
||||||
use G;
|
use G;
|
||||||
|
use MonologProvider;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass \G
|
||||||
|
*/
|
||||||
class gTest extends TestCase
|
class gTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -350,4 +354,27 @@ class gTest extends TestCase
|
|||||||
$this->assertContains($word, $res);
|
$this->assertContains($word, $res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests if the errors related to the trigger execution was registered
|
||||||
|
*
|
||||||
|
* @covers ::logTriggerExecution
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_check_log_trigger_execution()
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
$error = 'This is some error';
|
||||||
|
$_SESSION['_DATA_TRIGGER_']['_TRI_LOG_'] = false;
|
||||||
|
G::logTriggerExecution($data, $error, 'FATAL_ERROR', 60);
|
||||||
|
$log = MonologProvider::getSingleton('TriggerExecutionError', 'processmaker.log', true);
|
||||||
|
$this->assertNotEmpty($log->getPathFile());
|
||||||
|
$this->assertTrue($_SESSION['_DATA_TRIGGER_']['_TRI_LOG_']);
|
||||||
|
|
||||||
|
$_SESSION['_DATA_TRIGGER_']['_TRI_LOG_'] = false;
|
||||||
|
G::logTriggerExecution($data, '', '', 100);
|
||||||
|
$log = MonologProvider::getSingleton('TriggerExecution', 'processmaker.log', true);
|
||||||
|
$this->assertNotEmpty($log->getPathFile());
|
||||||
|
$this->assertFalse($_SESSION['_DATA_TRIGGER_']['_TRI_LOG_']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user