Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ZendMonitor.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Log/Writer/Abstract.php';
25 
35 {
41  protected $_isEnabled = true;
42 
48  protected $_isZendServer = false;
49 
53  public function __construct()
54  {
55  if (!function_exists('monitor_custom_event')) {
56  $this->_isEnabled = false;
57  }
58  if (function_exists('zend_monitor_custom_event')) {
59  $this->_isZendServer = true;
60  }
61  }
62 
69  static public function factory($config)
70  {
71  return new self();
72  }
73 
83  public function isEnabled()
84  {
85  return $this->_isEnabled;
86  }
87 
94  public function write($event)
95  {
96  if (!$this->isEnabled()) {
97  return;
98  }
99 
100  parent::write($event);
101  }
102 
109  protected function _write($event)
110  {
111  $priority = $event['priority'];
112  $message = $event['message'];
113  unset($event['priority'], $event['message']);
114 
115  if (!empty($event)) {
116  if ($this->_isZendServer) {
117  // On Zend Server; third argument should be the event
118  zend_monitor_custom_event($priority, $message, $event);
119  } else {
120  // On Zend Platform; third argument is severity -- either
121  // 0 or 1 -- and fourth is optional (event)
122  // Severity is either 0 (normal) or 1 (severe); classifying
123  // notice, info, and debug as "normal", and all others as
124  // "severe"
125  monitor_custom_event($priority, $message, ($priority > 4) ? 0 : 1, $event);
126  }
127  } else {
128  monitor_custom_event($priority, $message);
129  }
130  }
131 }
$config
Definition: fraud_order.php:17
$message