Logger.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\HttpKernel;
  11. use Symfony\Component\HttpKernel\Log\LoggerInterface;
  12. class Logger implements LoggerInterface
  13. {
  14. protected $logs;
  15. public function __construct()
  16. {
  17. $this->clear();
  18. }
  19. public function getLogs($priority = false)
  20. {
  21. return false === $priority ? $this->logs : $this->logs[$priority];
  22. }
  23. public function clear()
  24. {
  25. $this->logs = array(
  26. 'emerg' => array(),
  27. 'alert' => array(),
  28. 'crit' => array(),
  29. 'err' => array(),
  30. 'warn' => array(),
  31. 'notice' => array(),
  32. 'info' => array(),
  33. 'debug' => array(),
  34. );
  35. }
  36. public function log($message, $priority)
  37. {
  38. $this->logs[$priority][] = $message;
  39. }
  40. public function emerg($message, array $context = array())
  41. {
  42. $this->log($message, 'emerg');
  43. }
  44. public function alert($message, array $context = array())
  45. {
  46. $this->log($message, 'alert');
  47. }
  48. public function crit($message, array $context = array())
  49. {
  50. $this->log($message, 'crit');
  51. }
  52. public function err($message, array $context = array())
  53. {
  54. $this->log($message, 'err');
  55. }
  56. public function warn($message, array $context = array())
  57. {
  58. $this->log($message, 'warn');
  59. }
  60. public function notice($message, array $context = array())
  61. {
  62. $this->log($message, 'notice');
  63. }
  64. public function info($message, array $context = array())
  65. {
  66. $this->log($message, 'info');
  67. }
  68. public function debug($message, array $context = array())
  69. {
  70. $this->log($message, 'debug');
  71. }
  72. }