Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.05k stars 1.9k forks source link

Monolog\Level (enum) against Constants #1830

Open sumedia opened 1 year ago

sumedia commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Yes i understand, but consider the way:

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

What's about this?

stof commented 1 year ago

I don't understand what you code snippet is about

Seldaek commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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