WithLogLevel.php 750 B

12345678910111213141516171819202122232425262728293031
  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\Component\HttpKernel\Attribute;
  11. use Psr\Log\LogLevel;
  12. /**
  13. * @author Dejan Angelov <angelovdejan@protonmail.com>
  14. */
  15. #[\Attribute(\Attribute::TARGET_CLASS)]
  16. final class WithLogLevel
  17. {
  18. /**
  19. * @param LogLevel::* $level
  20. */
  21. public function __construct(public readonly string $level)
  22. {
  23. if (!\defined('Psr\Log\LogLevel::'.strtoupper($this->level))) {
  24. throw new \InvalidArgumentException(\sprintf('Invalid log level "%s".', $this->level));
  25. }
  26. }
  27. }