Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Abstract.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Log/Filter/Priority.php';
25 
35 {
39  protected $_filters = array();
40 
46  protected $_formatter;
47 
56  public function addFilter($filter)
57  {
58  if (is_int($filter)) {
59  $filter = new Zend_Log_Filter_Priority($filter);
60  }
61 
62  if (!$filter instanceof Zend_Log_Filter_Interface) {
64  #require_once 'Zend/Log/Exception.php';
65  throw new Zend_Log_Exception('Invalid filter provided');
66  }
67 
68  $this->_filters[] = $filter;
69  return $this;
70  }
71 
78  public function write($event)
79  {
81  foreach ($this->_filters as $filter) {
82  if (!$filter->accept($event)) {
83  return;
84  }
85  }
86 
87  // exception occurs on error
88  $this->_write($event);
89  }
90 
97  public function setFormatter(Zend_Log_Formatter_Interface $formatter)
98  {
99  $this->_formatter = $formatter;
100  return $this;
101  }
102 
108  public function shutdown()
109  {}
110 
117  abstract protected function _write($event);
118 
126  static protected function _parseConfig($config)
127  {
128  if ($config instanceof Zend_Config) {
129  $config = $config->toArray();
130  }
131 
132  if (!is_array($config)) {
133  #require_once 'Zend/Log/Exception.php';
134  throw new Zend_Log_Exception(
135  'Configuration must be an array or instance of Zend_Config'
136  );
137  }
138 
139  return $config;
140  }
141 }
setFormatter(Zend_Log_Formatter_Interface $formatter)
Definition: Abstract.php:97
$config
Definition: fraud_order.php:17
static _parseConfig($config)
Definition: Abstract.php:126