Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of SwiftMailer.
5
 * (c) 2004-2009 Chris Corbyn
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
/**
12
 * Logs to an Array backend.
13
 * @package Swift
14
 * @subpackage Transport
15
 * @author Chris Corbyn
16
 */
17
class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
18
{
19
 
20
  /**
21
   * The log contents.
22
   * @var array
23
   * @access private
24
   */
25
  private $_log = array();
26
 
27
  /**
28
   * Max size of the log.
29
   * @var int
30
   * @access private
31
   */
32
  private $_size = 0;
33
 
34
  /**
35
   * Create a new ArrayLogger with a maximum of $size entries.
36
   * @var int $size
37
   */
38
  public function __construct($size = 50)
39
  {
40
    $this->_size = $size;
41
  }
42
 
43
  /**
44
   * Add a log entry.
45
   * @param string $entry
46
   */
47
  public function add($entry)
48
  {
49
    $this->_log[] = $entry;
50
    while (count($this->_log) > $this->_size)
51
    {
52
      array_shift($this->_log);
53
    }
54
  }
55
 
56
  /**
57
   * Clear the log contents.
58
   */
59
  public function clear()
60
  {
61
    $this->_log = array();
62
  }
63
 
64
  /**
65
   * Get this log as a string.
66
   * @return string
67
   */
68
  public function dump()
69
  {
70
    return implode(PHP_EOL, $this->_log);
71
  }
72
 
73
}