diff --git a/src/app/code/community/FireGento/Logger/Helper/Data.php b/src/app/code/community/FireGento/Logger/Helper/Data.php index f32f0c63..24cee917 100644 --- a/src/app/code/community/FireGento/Logger/Helper/Data.php +++ b/src/app/code/community/FireGento/Logger/Helper/Data.php @@ -32,6 +32,7 @@ class FireGento_Logger_Helper_Data extends Mage_Core_Helper_Abstract protected $_targets; protected $_targetMap; + protected $_targetsForFilename = []; protected $_notificationRules; protected $_maxBacktraceLines; protected $_maxDataLength; @@ -97,21 +98,24 @@ public function getMappedTargets($filename) if ($this->_targetMap === null) { $targetMap = $this->getLoggerConfig('general/target_map'); if ($targetMap && ($targetMap = @unserialize($targetMap))) { - $targets = array(); - foreach ($targetMap as $map) { - if (@preg_match('/^'.$map['pattern'].'$/', $filename)) { - $targets[$map['target']] = (int) $map['backtrace']; - if ((int) $map['stop_on_match']) { - break; - } + $this->_targetMap = $targetMap; + } else { + $this->_targetMap = []; + } + } + if ( ! isset($this->_targetsForFilename[$filename])) { + $targets = array(); + foreach ($this->_targetMap as $map) { + if (@preg_match('/^'.str_replace('/', '\\/', $map['pattern']).'$/', $filename)) { + $targets[$map['target']] = (int) $map['backtrace']; + if ((int) $map['stop_on_match']) { + break; } } - $this->_targetMap = $targets; - } else { - $this->_targetMap = false; } + $this->_targetsForFilename[$filename] = $targets; } - return $this->_targetMap; + return $this->_targetsForFilename[$filename]; } /** @@ -170,7 +174,7 @@ public function addEventMetadata(&$event, $notAvailable = null, $enableBacktrace ->setStoreCode(Mage::app()->getStore()->getCode()); // Add admin user data - if (Mage::app()->getStore()->isAdmin() && isset($_SESSION['admin'])) { + if (Mage::app()->getStore()->isAdmin() && isset($_SESSION) && isset($_SESSION['admin'])) { $session = Mage::getSingleton('admin/session'); if ($session->isLoggedIn()) { $event->setAdminUserId($session->getUser()->getId()); diff --git a/src/app/code/community/FireGento/Logger/Model/Logstash.php b/src/app/code/community/FireGento/Logger/Model/Logstash.php index 6d720bf6..66ef75b7 100644 --- a/src/app/code/community/FireGento/Logger/Model/Logstash.php +++ b/src/app/code/community/FireGento/Logger/Model/Logstash.php @@ -83,7 +83,7 @@ protected function buildJSONMessage($event, $enableBacktrace = false) $fields['HttpHost'] = (!Mage::app()->getRequest()->getHttpHost()) ? 'cli': Mage::app()->getRequest()->getHttpHost(); $fields['LogFileName'] = $this->_logFileName; // Only add session fields if a session was already instantiated and logger should not start a new session - if (isset($_SESSION)) { + if (isset($_SESSION) && isset($_SESSION['core'])) { $fields['SessionId'] = Mage::getSingleton("core/session")->getEncryptedSessionId(); $fields['CustomerId'] = Mage::getSingleton('customer/session')->getCustomerId(); } diff --git a/src/app/code/community/FireGento/Logger/etc/config.xml b/src/app/code/community/FireGento/Logger/etc/config.xml index 77fbf648..261b31ec 100644 --- a/src/app/code/community/FireGento/Logger/etc/config.xml +++ b/src/app/code/community/FireGento/Logger/etc/config.xml @@ -209,7 +209,8 @@ - advanced + default,advanced + a:2:{s:18:"_1575507325664_664";a:4:{s:7:"pattern";s:26:"system\.log|exception\.log";s:6:"target";s:8:"advanced";s:9:"backtrace";s:1:"1";s:13:"stop_on_match";s:1:"1";}s:18:"_1575507340100_100";a:4:{s:7:"pattern";s:2:".*";s:6:"target";s:7:"default";s:9:"backtrace";s:1:"0";s:13:"stop_on_match";s:1:"1";}} 7