Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LoggerProxy.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class LoggerProxy implements LoggerInterface
11 {
15  const CONF_GROUP_NAME = 'db_logger';
16 
20  const PARAM_ALIAS = 'output';
21 
25  const PARAM_LOG_ALL = 'log_everything';
26 
30  const PARAM_QUERY_TIME = 'query_time_threshold';
31 
35  const PARAM_CALL_STACK = 'include_stacktrace';
36 
40  const LOGGER_ALIAS_FILE = 'file';
41 
45  const LOGGER_ALIAS_DISABLED = 'disabled';
46 
50  private $logger;
51 
55  private $fileFactory;
56 
60  private $quietFactory;
61 
65  private $loggerAlias;
66 
70  private $logAllQueries;
71 
75  private $logQueryTime;
76 
80  private $logCallStack;
81 
91  public function __construct(
92  FileFactory $fileFactory,
93  QuietFactory $quietFactory,
94  $loggerAlias,
95  $logAllQueries = true,
96  $logQueryTime = 0.001,
97  $logCallStack = true
98  ) {
99  $this->fileFactory = $fileFactory;
100  $this->quietFactory = $quietFactory;
101  $this->loggerAlias = $loggerAlias;
102  $this->logAllQueries = $logAllQueries;
103  $this->logQueryTime = $logQueryTime;
104  $this->logCallStack = $logCallStack;
105  }
106 
111  private function getLogger()
112  {
113  if ($this->logger === null) {
114  switch ($this->loggerAlias) {
116  $this->logger = $this->fileFactory->create(
117  [
118  'logAllQueries' => $this->logAllQueries,
119  'logQueryTime' => $this->logQueryTime,
120  'logCallStack' => $this->logCallStack,
121  ]
122  );
123  break;
124  default:
125  $this->logger = $this->quietFactory->create();
126  break;
127  }
128  }
129  return $this->logger;
130  }
131 
138  public function log($str)
139  {
140  $this->getLogger()->log($str);
141  }
142 
150  public function logStats($type, $sql, $bind = [], $result = null)
151  {
152  $this->getLogger()->logStats($type, $sql, $bind, $result);
153  }
154 
159  public function critical(\Exception $exception)
160  {
161  $this->getLogger()->critical($exception);
162  }
163 
167  public function startTimer()
168  {
169  $this->getLogger()->startTimer();
170  }
171 }
$type
Definition: item.phtml:13
__construct(FileFactory $fileFactory, QuietFactory $quietFactory, $loggerAlias, $logAllQueries=true, $logQueryTime=0.001, $logCallStack=true)
Definition: LoggerProxy.php:91
logStats($type, $sql, $bind=[], $result=null)