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

fixes #342 add rfc option for syslogudp handler #343

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
make node is enum
gwinn committed Mar 31, 2021
commit b91d639a53907829f287e6b40315ffe487a664b4
8 changes: 6 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Monolog\Logger;
use Monolog\Handler\SyslogUdpHandler;

/**
* This class contains the configuration information for the bundle
@@ -162,7 +163,7 @@
* - [level]: level name or int value, defaults to DEBUG
* - [bubble]: bool, defaults to true
* - [ident]: string, defaults to
* - [rfc]: int 0 (RFC3164) or 1 (RFC5424), defaults to 1
* - [rfc]: RFC3164 or RFC5424, defaults to RFC5424
*
* - swift_mailer:
* - from_email: optional if email_prototype is given
@@ -495,7 +496,10 @@ public function getConfigTreeBuilder()
->scalarNode('title')->defaultNull()->end() // pushover
->scalarNode('host')->defaultNull()->end() // syslogudp & hipchat
->scalarNode('port')->defaultValue(514)->end() // syslogudp
->integerNode('rfc')->defaultValue(1)->end() // syslogudp
->enumNode('rfc')
->values([SyslogUdpHandler::RFC5424, SyslogUdpHandler::RFC3164])
Copy link
Contributor

Choose a reason for hiding this comment

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

What about RFC5424e?

If we add this, we probably need to be careful, not to rely on the constant as UdpHandler in Monolog 1 does not support it

Copy link
Author

Choose a reason for hiding this comment

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

That's why i'm not sure about this RFC at this moment.
Should it be added at UdpHandler in Monolog 1? Or should it be added in some other place and imported alongside with SuslogUdpHandler for Monolog v1.x?

Copy link
Contributor

@dbrumann dbrumann Jan 28, 2021

Choose a reason for hiding this comment

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

I am not sure how actively maintained v1 is, i.e. whether new features are accepted and if this is considered a new feature.

Both UdpHandler v1 and v2 will just ignore invalid values as far as I can tell. I think we can just allow users to put in whatever int they want, maybe add a comment for where to find the proper values (e.g. "see UdpHandler RFC-constants") and not bother with the constants at all. Not sure what others think about this, though.

edit: I just looked at the handlers again and it seems specifying an invalid int will at least trigger a notice about an illegal array offset, but I think that could be easily fixed using an array_key_exists()-check with a fallback.

Copy link
Author

Choose a reason for hiding this comment

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

Well, i think we should leave this story as is at this moment, we can add support for RFC5424e into another PR to speed up the acceptance of the current request

Copy link
Member

Choose a reason for hiding this comment

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

using raw value (cf snippet bellow) would allow people to use the RFC, without triggering exception for composer 1

Suggested change
->values([SyslogUdpHandler::RFC5424, SyslogUdpHandler::RFC3164])
->values([SyslogUdpHandler::RFC5424, SyslogUdpHandler::RFC3164, 2 /* SyslogUdpHandler::RFC5424e */])

Copy link
Author

Choose a reason for hiding this comment

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

#343 (comment) here @Tobion suggest to not to use plain values, which point of view should I adhere to

Copy link
Member

Choose a reason for hiding this comment

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

It's always better to use constant, that's why @Tobion suggested to not use plain value when a constant exists.

In this case (and only for the value 2), we can not use constant, as the constant does not exist in monolog 1.
But we should not prevent people that use monolog 2 to use this value.
As a result, you should either remove this ENUM constraint and let people enter whatever they want, or allows this rfc by using a plain value.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, i'll change it to scalarNode with default value

->defaultValue(SyslogUdpHandler::RFC5424)
->end() // syslogudp
->arrayNode('publisher')
->canBeUnset()
->beforeNormalization()