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

Monolog\Level (enum) against Constants #1830

Open
sumedia opened this issue Aug 13, 2023 · 6 comments
Open

Monolog\Level (enum) against Constants #1830

sumedia opened this issue Aug 13, 2023 · 6 comments
Labels

Comments

@sumedia
Copy link

sumedia commented Aug 13, 2023

Hi,

i'm currently not understand why removing the level constants from Monolog, which has a proper and changeable definition of the right level for monolog.
Instead i should use a enum Monolog\Level, which does in the end exactly the same.
Give a valid Errorlevel.
I'm forced to, now!
What are the advantages of this?
I can only consider it as usefull to convert invalid Levels inside the application.
It's a deprecated world :D

Regards

Sven

@Seldaek
Copy link
Owner

Seldaek commented Oct 27, 2023

The Enum gives you a clear list of all possible values, and indeed it makes it impossible to add new ones, which was always a bad idea IMO. Not sure what you are missing or trying to achieve 🤷🏻‍♂️

@sumedia
Copy link
Author

sumedia commented Oct 27, 2023

Yes i understand, but consider the way:

myFunction($var) {
$code = ENUM::get($var);
}

What's about this?

@stof
Copy link
Contributor

stof commented Oct 27, 2023

I don't understand what you code snippet is about

@Seldaek
Copy link
Owner

Seldaek commented Oct 27, 2023

You mean Level::from($var)? Have you looked how enum work in php? See https://www.php.net/manual/en/language.enumerations.backed.php

@Seldaek
Copy link
Owner

Seldaek commented Oct 27, 2023

Level instances also have convenient ways to get other standard level types from them this is something you couldn't do with constants https://github.com/Seldaek/monolog/blob/main/src/Monolog/Level.php#L150-L187

@sumedia
Copy link
Author

sumedia commented Oct 28, 2023

Why was it a bad idea?
I have first to review the reason why i wrote this, it's some time ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants