PageRenderTime 37ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/swift/Swift/Log/DefaultLog.php

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