FluentdFormatterTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  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 Monolog\Formatter;
  11. use Monolog\Logger;
  12. use Monolog\TestCase;
  13. class FluentdFormatterTest extends TestCase
  14. {
  15. /**
  16. * @covers Monolog\Formatter\FluentdFormatter::__construct
  17. * @covers Monolog\Formatter\FluentdFormatter::isUsingLevelsInTag
  18. */
  19. public function testConstruct()
  20. {
  21. $formatter = new FluentdFormatter();
  22. $this->assertEquals(false, $formatter->isUsingLevelsInTag());
  23. $formatter = new FluentdFormatter(false);
  24. $this->assertEquals(false, $formatter->isUsingLevelsInTag());
  25. $formatter = new FluentdFormatter(true);
  26. $this->assertEquals(true, $formatter->isUsingLevelsInTag());
  27. }
  28. /**
  29. * @covers Monolog\Formatter\FluentdFormatter::format
  30. */
  31. public function testFormat()
  32. {
  33. $record = $this->getRecord(Logger::WARNING);
  34. $record['datetime'] = new \DateTime("@0");
  35. $formatter = new FluentdFormatter();
  36. $this->assertEquals(
  37. '["test", 0, {"message":"test","level":300,"level_name":"WARNING","extra":[]}]',
  38. $formatter->format($record));
  39. $formatter = new FluentdFormatter(true);
  40. $this->assertEquals(
  41. '["test.warning", 0, {"message":"test","level":300,"level_name":"WARNING","extra":[]}]',
  42. $formatter->format($record));
  43. }
  44. }