1<?php
2
3/**
4 * Swift Mailer Default Logger
5 * Please read the LICENSE file
6 * @copyright Chris Corbyn <chris@w3style.co.uk>
7 * @author Chris Corbyn <chris@w3style.co.uk>
8 * @package Swift_Log
9 * @license GNU Lesser General Public License
10 */
11
12require_once dirname(__FILE__) . "/../ClassLoader.php";
13Swift_ClassLoader::load("Swift_Log");
14
15/**
16 * The Default Logger class
17 * @package Swift_Log
18 * @author Chris Corbyn <chris@w3style.co.uk>
19 */
20class Swift_Log_DefaultLog extends Swift_Log
21{
22  /**
23   * Lines in the log
24   * @var array
25   */
26  protected $entries = array();
27
28  /**
29   * Add a log entry
30   * @param string The text for this entry
31   * @param string The label for the type of entry
32   */
33  public function add($text, $type = self::NORMAL)
34  {
35    $this->entries[] = $type . " " . $text;
36    if ($this->getMaxSize() > 0) $this->entries = array_slice($this->entries, (-1 * $this->getMaxSize()));
37  }
38  /**
39   * Dump the contents of the log to the browser.
40   * @param boolean True if the string should be returned rather than output.
41   */
42  public function dump($return_only=false)
43  {
44    $ret = implode("\n", $this->entries);
45    if (!$return_only) echo $ret;
46    else return $ret;
47  }
48  /**
49   * Empty the log
50   */
51  public function clear()
52  {
53    $this->failedRecipients = null;
54    $this->failedRecipients = array();
55    $this->entries = null;
56    $this->entries = array();
57  }
58}
59