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 priority field to processor tags #421

Closed
wants to merge 1 commit into from
Closed

Conversation

sudo-plz
Copy link

@sudo-plz sudo-plz commented Nov 4, 2021

So that the order in which the processors are used by monolog can be determined.

Example config:

    Foo\Bar\Log\Processors\FirstProcessor:
        tags:
            - { name: monolog.processor, channel: http }

    Foo\Bar\Log\Processors\SecondProcessor:
        tags:
            - { name: monolog.processor, channel: http, priority: -10 } # last

    Foo\Bar\Log\Processors\ThirdProcessor:
        tags:
            - { name: monolog.processor, channel: http, priority: -20 } # very last

So that the order in which the processors are used by monolog can be
determined.
@sudo-plz sudo-plz marked this pull request as ready for review November 4, 2021 14:27
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks proposing this new feature. I think can be useful in rare cases the processors are dependent on each other.

It needs to be rebased on master. Features of PHP 7.1+ can be used.

usort(
$processors,
function (array $left, array $right) {
return $left['tag']['priority'] - $right['tag']['priority'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spaceship operator is designed for this use-case.

Suggested change
return $left['tag']['priority'] - $right['tag']['priority'];
return $left['tag']['priority'] <=> $right['tag']['priority'];

@sudo-plz
Copy link
Author

Closed in favor of #455

@sudo-plz sudo-plz closed this Mar 17, 2023
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.

None yet

3 participants