Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getDefaultTarget to Dispatcher #14283

Merged
merged 4 commits into from
Feb 3, 2024
Merged

Conversation

timkelty
Copy link
Contributor

@timkelty timkelty commented Feb 3, 2024

Getting the current active Monolog logger is a pain, as you need to look at all the targets (web, console, queue) and get the enabled one. This provides a method to streamline that.

With this, regardless of your context, to, eg, call Monolog\Logger::reset(), you can do:

Craft::$app->getLog()->getDefaultTarget()->getLogger()->reset();

It also renames getTargets -> getDefaultTargets, as it got confusing because was explicitly not a getter for the target property.

Related Issues

@timkelty timkelty changed the base branch from develop to 5.0 February 3, 2024 03:03
@timkelty timkelty requested a review from brandonkelly February 3, 2024 03:13
@brandonkelly brandonkelly merged commit 0682daa into 5.0 Feb 3, 2024
@brandonkelly brandonkelly deleted the feature/getDefaultTarget branch February 3, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants