-
Notifications
You must be signed in to change notification settings - Fork 0
/
BufferLogger.php
67 lines (60 loc) · 1.68 KB
/
BufferLogger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* @author stev leibelt <artodeto@arcor.de>
* @since 8/27/13
*/
namespace Net\Bazzline\Component\ProxyLogger\Logger;
use Net\Bazzline\Component\ProxyLogger\Event\BufferEvent;
/**
* Class BufferLogger
*
* @package Net\Bazzline\Component\ProxyLogger\Logger
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-27
*/
class BufferLogger extends AbstractProxyLogger implements BufferLoggerInterface
{
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-27
*/
public function log($level, $message, array $context = array())
{
$logRequest = $this->logRequestFactory->create($level, $message, $context);
$this->event->setLogRequest($logRequest);
$this->event->setLoggerCollection($this->loggers);
$this->dispatcher->dispatch(BufferEvent::ADD_LOG_REQUEST_TO_BUFFER, $this->event);
}
/**
* Flush buffer content to logger
*
* @return $this
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-27
*/
public function flush()
{
$this->event->setLoggerCollection($this->loggers);
$this->dispatcher->dispatch(BufferEvent::FLUSH_BUFFER, $this->event);
return $this;
}
/**
* Cleans buffer
*
* @return $this
* @author stev leibelt <artodeto@arcor.de>
* @since 2013-08-27
*/
public function clean()
{
$this->event->setLoggerCollection($this->loggers);
$this->dispatcher->dispatch(BufferEvent::CLEAN_BUFFER, $this->event);
return $this;
}
}