Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
File.php
Go to the documentation of this file.
1 <?php
7 
11 
15 class File extends LoggerAbstract
16 {
20  private $dir;
21 
27  protected $debugFile;
28 
36  public function __construct(
38  $debugFile = 'debug/db.log',
39  $logAllQueries = false,
40  $logQueryTime = 0.05,
41  $logCallStack = false
42  ) {
43  parent::__construct($logAllQueries, $logQueryTime, $logCallStack);
44  $this->dir = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
45  $this->debugFile = $debugFile;
46  }
47 
51  public function log($str)
52  {
53  $str = '## ' . date('Y-m-d H:i:s') . "\r\n" . $str;
54 
55  $stream = $this->dir->openFile($this->debugFile, 'a');
56  $stream->lock();
57  $stream->write($str);
58  $stream->unlock();
59  $stream->close();
60  }
61 
65  public function logStats($type, $sql, $bind = [], $result = null)
66  {
67  $stats = $this->getStats($type, $sql, $bind, $result);
68  if ($stats) {
69  $this->log($stats);
70  }
71  }
72 
76  public function critical(\Exception $e)
77  {
78  $this->log("EXCEPTION \n$e\n\n");
79  }
80 }
critical(\Exception $e)
Definition: File.php:76
$type
Definition: item.phtml:13
getStats($type, $sql, $bind=[], $result=null)
logStats($type, $sql, $bind=[], $result=null)
Definition: File.php:65
__construct(Filesystem $filesystem, $debugFile='debug/db.log', $logAllQueries=false, $logQueryTime=0.05, $logCallStack=false)
Definition: File.php:36
$filesystem