1 | <?php |
||
18 | class DataObjectHandler extends AbstractProcessingHandler |
||
19 | { |
||
20 | /** |
||
21 | * The default DataObject to use for storing log entries |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | const DEFAULT_CLASS = 'SilverLeague\\LogViewer\\Model\\LogEntry'; |
||
26 | |||
27 | /** |
||
28 | * The default DateTime format to use for storing the log timestamp |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | const DEFAULT_DATETIME_FORMAT = 'Y-m-d H:i:s'; |
||
33 | |||
34 | /** |
||
35 | * DataObject class for storing log entries |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $objectClass; |
||
40 | |||
41 | /** |
||
42 | * @param string $objectClass The DataObject class to use for handling the write |
||
43 | * @param int $level The minimum logging level at which this handler will be triggered (configurable) |
||
44 | * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not |
||
45 | */ |
||
46 | public function __construct($objectClass = self::DEFAULT_CLASS, $level = Logger::DEBUG, $bubble = true) |
||
52 | |||
53 | /** |
||
54 | * {@inheritDoc} |
||
55 | */ |
||
56 | protected function getDefaultFormatter() |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | protected function write(array $record) |
||
68 | |||
69 | /** |
||
70 | * Create a new DataObject instance and set the log information to it |
||
71 | * |
||
72 | * @param string $message The log message |
||
73 | * @param string $level The log level text, e.g. "DEBUG" |
||
74 | * @return int The written DataObject ID |
||
75 | */ |
||
76 | public function addDataObject($message, $level) |
||
87 | |||
88 | /** |
||
89 | * Set the DataObject to use for storing log entries |
||
90 | * |
||
91 | * @param string $class |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function setObjectClass($class) |
||
99 | |||
100 | /** |
||
101 | * Get the DataObject to use for storing log entries |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getObjectClass() |
||
109 | |||
110 | /** |
||
111 | * Get the minimum Monolog\Logger log level to start catching messages at |
||
112 | * |
||
113 | * @see \Monolog\Logger |
||
114 | * @return int |
||
115 | */ |
||
116 | public function getMinimumLogLevel() |
||
120 | } |
||
121 |