Skip to content

Commit 30f93d4

Browse files
authored
Merge pull request #17 from homiedopie/feature/INV-1576-1567
Fix log function and get trace checking
2 parents 33a36fb + cbbbd9f commit 30f93d4

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/Stackify/Log/Builder/MessageBuilder.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,18 @@ protected function getErrorItem(ErrorWrapper $errorWrapper)
9494
$errorItem->ErrorType = $errorWrapper->getType();
9595
$errorItem->ErrorTypeCode = $errorWrapper->getCode();
9696
$errorItem->SourceMethod = $errorWrapper->getSourceMethod();
97-
foreach ($errorWrapper->getTrace() as $index => $trace) {
98-
$errorItem->StackTrace[] = new TraceFrame(
99-
$trace['file'],
100-
$trace['line'],
101-
$trace['function']
102-
);
97+
98+
$errorWrapperTrace = $errorWrapper->getTrace();
99+
if ($errorWrapperTrace && is_array($errorWrapperTrace)) {
100+
foreach ($errorWrapper->getTrace() as $index => $trace) {
101+
$errorItem->StackTrace[] = new TraceFrame(
102+
$trace['file'],
103+
$trace['line'],
104+
$trace['function']
105+
);
106+
}
103107
}
108+
104109
$previous = $errorWrapper->getInnerError();
105110
if ($previous) {
106111
$errorItem->InnerError = $this->getErrorItem($previous);

src/Stackify/Log/Transport/Config/AbstractConfig.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function setCaptureErrorCookiesBlacklist($rawConfig = null)
391391
public function setDebugLogPath($path)
392392
{
393393
if ($path == null) {
394-
$this->log('[DebugLogPath] is not valid.');
394+
$this->logError('[DebugLogPath] is not valid.');
395395
return;
396396
}
397397

@@ -636,8 +636,12 @@ protected function logDebug($message)
636636
*
637637
* @return void
638638
*/
639-
protected function log($message, $args, $success = true)
639+
protected function log($message, $args = null, $success = true)
640640
{
641+
if ($args == null) {
642+
$args = array();
643+
}
644+
641645
$replacements = array_slice($args, 1);
642646
$prefix = $success ? 'Stackify Log' : 'Stackify Error';
643647
$template = "[$prefix][Config] $message";
@@ -661,7 +665,7 @@ protected function log($message, $args, $success = true)
661665
public function extract($config = null)
662666
{
663667
if (is_array($config) == false) {
664-
$this->log('['. __CLASS__ .']['. __FUNCTION__ .'] $config is not an array.');
668+
$this->logDebug('['. __CLASS__ .']['. __FUNCTION__ .'] $config is not an array.');
665669
return;
666670
}
667671

@@ -674,7 +678,7 @@ public function extract($config = null)
674678
continue;
675679
}
676680

677-
$this->log('['. __CLASS__ .']['. __FUNCTION__ .']' . $method .' does not exists.');
681+
$this->logDebug('['. __CLASS__ .']['. __FUNCTION__ .']' . $method .' does not exists.');
678682
}
679683
}
680684
}
@@ -716,7 +720,7 @@ protected function parseStringToArray($string = null, $property = null)
716720
protected function getBoolean($enable = null, $property = null)
717721
{
718722
if (is_bool($enable) == false) {
719-
$this->log('['.$property.'] is not a boolean.');
723+
$this->logError('['.$property.'] is not a boolean.');
720724
return null;
721725
}
722726

src/Stackify/Log/Transport/Config/Agent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public function getApiVersionHeader()
408408
*
409409
* @return void
410410
*/
411-
protected function log($message, $args, $success = true)
411+
protected function log($message, $args = null, $success = true)
412412
{
413413
return parent::log('['.get_class().']'.$message, $args, $success);
414414
}

0 commit comments

Comments
 (0)