Log.php 737 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Illuminate\Container\Attributes;
  3. use Attribute;
  4. use Illuminate\Contracts\Container\Container;
  5. use Illuminate\Contracts\Container\ContextualAttribute;
  6. #[Attribute(Attribute::TARGET_PARAMETER)]
  7. class Log implements ContextualAttribute
  8. {
  9. /**
  10. * Create a new class instance.
  11. */
  12. public function __construct(public ?string $channel = null)
  13. {
  14. }
  15. /**
  16. * Resolve the log channel.
  17. *
  18. * @param self $attribute
  19. * @param \Illuminate\Contracts\Container\Container $container
  20. * @return \Psr\Log\LoggerInterface
  21. */
  22. public static function resolve(self $attribute, Container $container)
  23. {
  24. return $container->make('log')->channel($attribute->channel);
  25. }
  26. }