Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractModel.php
Go to the documentation of this file.
1 <?php
7 
9 
16 {
22  protected $_debugMode = false;
23 
30 
36  protected $_logTrace = [];
37 
41  protected $_logger;
42 
46  protected $_varDirectory;
47 
53  public function __construct(
54  \Psr\Log\LoggerInterface $logger,
55  \Magento\Framework\Filesystem $filesystem,
56  array $data = []
57  ) {
58  $this->_logger = $logger;
59  $this->_varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
60  parent::__construct($data);
61  }
62 
70  public function addLogComment($debugData)
71  {
72  if (is_array($debugData)) {
73  $this->_logTrace = array_merge($this->_logTrace, $debugData);
74  } else {
75  $this->_logTrace[] = $debugData;
76  }
77 
78  if ($this->_debugMode) {
79  $this->_logger->debug(var_export($debugData, true));
80  }
81 
82  return $this;
83  }
84 
90  public function getFormatedLogTrace()
91  {
92  $trace = '';
93  $lineNumber = 1;
94  foreach ($this->_logTrace as &$info) {
95  $trace .= $lineNumber++ . ': ' . $info . "\n";
96  }
97  return $trace;
98  }
99 }
$logger
__construct(\Psr\Log\LoggerInterface $logger, \Magento\Framework\Filesystem $filesystem, array $data=[])
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52
$filesystem