scratch – Blame information for rev 115

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 /*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11  
12 namespace Monolog\Handler;
13  
14 /**
15 * Base class for all mail handlers
16 *
17 * @author Gyula Sallai
18 */
19 abstract class MailHandler extends AbstractProcessingHandler
20 {
21 /**
22 * {@inheritdoc}
23 */
24 public function handleBatch(array $records)
25 {
26 $messages = array();
27  
28 foreach ($records as $record) {
29 if ($record['level'] < $this->level) {
30 continue;
31 }
32 $messages[] = $this->processRecord($record);
33 }
34  
35 if (!empty($messages)) {
36 $this->send((string) $this->getFormatter()->formatBatch($messages), $messages);
37 }
38 }
39  
40 /**
41 * Send a mail with the given content
42 *
43 * @param string $content formatted email body to be sent
44 * @param array $records the array of log records that formed this content
45 */
46 abstract protected function send($content, array $records);
47  
48 /**
49 * {@inheritdoc}
50 */
51 protected function write(array $record)
52 {
53 $this->send((string) $record['formatted'], array($record));
54 }
55  
56 protected function getHighestRecord(array $records)
57 {
58 $highestRecord = null;
59 foreach ($records as $record) {
60 if ($highestRecord === null || $highestRecord['level'] < $record['level']) {
61 $highestRecord = $record;
62 }
63 }
64  
65 return $highestRecord;
66 }
67 }