[GH-ISSUE #1785] Level_name options #754

Open
opened 2026-03-04 02:17:41 +03:00 by kerem · 1 comment
Owner

Originally created by @funtus00 on GitHub (Dec 21, 2022).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1785

It would be great to have optional level_name name. For example NLog has feature to make level_name as 1, 3 letters or full name.
Current situation (log strings):

[2022-21-12 10:10:01.718][INFO][127.0.0.1] '6': user login
[2022-21-12 10:10:01.724][WARNING][127.0.0.1] '6': domain gmail.com is forbidden to use or does not exist
[2022-21-12 10:10:01.724][ERROR][127.0.0.1] '6': user email is forbidden to use

If set it level_name as 1 or 3 letters logs can be like this:

[2022-21-12 10:10:01.718][INF][127.0.0.1] '6': user login
[2022-21-12 10:10:01.724][WRN][127.0.0.1] '6': domain gmail.com is forbidden to use or does not exist
[2022-21-12 10:10:01.724][ERR][127.0.0.1] '6': user email is forbidden to use

[2022-21-12 10:10:01.718][I][127.0.0.1] '6': user login
[2022-21-12 10:10:01.724][W][127.0.0.1] '6': domain gmail.com is forbidden to use or does not exist
[2022-21-12 10:10:01.724][E][127.0.0.1] '6': user email is forbidden to use

It helps to read logs.
Idea do make option:
INFO = INF = I
ERROR = ERR = E
WARNING = WRN = W
DEBUG = DBG = D
and so on...

Originally created by @funtus00 on GitHub (Dec 21, 2022). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1785 It would be great to have optional level_name name. For example NLog has feature to make level_name as 1, 3 letters or full name. Current situation (log strings): [2022-21-12 10:10:01.718][INFO][127.0.0.1] '6': user login [2022-21-12 10:10:01.724][WARNING][127.0.0.1] '6': domain gmail.com is forbidden to use or does not exist [2022-21-12 10:10:01.724][ERROR][127.0.0.1] '6': user email is forbidden to use If set it level_name as 1 or 3 letters logs can be like this: [2022-21-12 10:10:01.718][INF][127.0.0.1] '6': user login [2022-21-12 10:10:01.724][WRN][127.0.0.1] '6': domain gmail.com is forbidden to use or does not exist [2022-21-12 10:10:01.724][ERR][127.0.0.1] '6': user email is forbidden to use [2022-21-12 10:10:01.718][I][127.0.0.1] '6': user login [2022-21-12 10:10:01.724][W][127.0.0.1] '6': domain gmail.com is forbidden to use or does not exist [2022-21-12 10:10:01.724][E][127.0.0.1] '6': user email is forbidden to use It helps to read logs. Idea do make option: INFO = INF = I ERROR = ERR = E WARNING = WRN = W DEBUG = DBG = D and so on...
Author
Owner

@Seldaek commented on GitHub (Feb 4, 2023):

So this would be for LineFormatter only right? Probably could easily be added as an additional option via a setMaxLevelNameLength(1)? Would you like to send a PR?

<!-- gh-comment-id:1416848397 --> @Seldaek commented on GitHub (Feb 4, 2023): So this would be for LineFormatter only right? Probably could easily be added as an additional option via a `setMaxLevelNameLength(1)`? Would you like to send a PR?
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#754
No description provided.