[GH-ISSUE #1830] Monolog\Level (enum) against Constants #781

Closed
opened 2026-03-04 02:17:55 +03:00 by kerem · 6 comments
Owner

Originally created by @sumedia on GitHub (Aug 13, 2023).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1830

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

Originally created by @sumedia on GitHub (Aug 13, 2023). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1830 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
kerem 2026-03-04 02:17:55 +03:00
  • closed this issue
  • added the
    Support
    label
Author
Owner

@Seldaek commented on GitHub (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 🤷🏻‍♂️

<!-- gh-comment-id:1782903071 --> @Seldaek commented on GitHub (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 🤷🏻‍♂️
Author
Owner

@sumedia commented on GitHub (Oct 27, 2023):

Yes i understand, but consider the way:

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

What's about this?

<!-- gh-comment-id:1782958943 --> @sumedia commented on GitHub (Oct 27, 2023): Yes i understand, but consider the way: myFunction($var) { $code = ENUM::get($var); } What's about this?
Author
Owner

@stof commented on GitHub (Oct 27, 2023):

I don't understand what you code snippet is about

<!-- gh-comment-id:1782960552 --> @stof commented on GitHub (Oct 27, 2023): I don't understand what you code snippet is about
Author
Owner

@Seldaek commented on GitHub (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

<!-- gh-comment-id:1782961323 --> @Seldaek commented on GitHub (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
Author
Owner

@Seldaek commented on GitHub (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

<!-- gh-comment-id:1782963084 --> @Seldaek commented on GitHub (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
Author
Owner

@sumedia commented on GitHub (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.

<!-- gh-comment-id:1783921079 --> @sumedia commented on GitHub (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 in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#781
No description provided.