EchoLogger.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Prints all log messages in real time.
  11. *
  12. * @package Swift
  13. * @subpackage Transport
  14. * @author Chris Corbyn
  15. */
  16. class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger
  17. {
  18. /** Whether or not HTML should be output */
  19. private $_isHtml;
  20. /**
  21. * Create a new EchoLogger.
  22. *
  23. * @param boolean $isHtml
  24. */
  25. public function __construct($isHtml = true)
  26. {
  27. $this->_isHtml = $isHtml;
  28. }
  29. /**
  30. * Add a log entry.
  31. * @param string $entry
  32. */
  33. public function add($entry)
  34. {
  35. if ($this->_isHtml) {
  36. printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '<br />', PHP_EOL);
  37. } else {
  38. printf('%s%s', $entry, PHP_EOL);
  39. }
  40. }
  41. /**
  42. * Not implemented.
  43. */
  44. public function clear()
  45. {
  46. }
  47. /**
  48. * Not implemented.
  49. */
  50. public function dump()
  51. {
  52. }
  53. }