Should the
LoggerChannelTrait
be deprecated, then, to encourage service injection and discourage new uses of the trait?- πΊπΈUnited States mile23 Seattle, WA
Searching through Drupal 11, I see that: A) LoggerChannelTrait is unused within core, and B) therefore no services follow this pattern. That's a step forward, I'd say... I assume the trait is still in use in contrib, which is why it's not deprecated at this point though maybe it should be.
Also, core now defines logger channels as services, rather than the factory, so you see this pattern in core.services.yml:
logger.channel_base: abstract: true class: Drupal\Core\Logger\LoggerChannel factory: ['@logger.factory', 'get'] logger.channel.default: parent: logger.channel_base arguments: ['system'] logger.channel.php: parent: logger.channel_base arguments: ['php'] ... views.entity_schema_subscriber: class: Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber arguments: ['@entity_type.manager', '@logger.channel.default']
So yay, even better.
Yes, there are plenty of uses in contrib.
Deprecating it would probably help encourage contrib to use injection.