Closed wurst-hans closed 3 years ago
Same here. I see that Logger::getLevels() are hard coded lowercase. But why?
@kowach @wurst-hans Can you guys have a look at this PR?
https://github.com/phalcon/cphalcon/pull/15401
Maybe I am setting the test wrong but that is how I understood it from your description. Any pointers welcome.
Thanks!
Sorry, don't understand much of testing, but as I see in your PR, the test expects $expected = '[info] info message ' . $unique;
but shouldn't it be $expected = '[INFO] info message ' . $unique;
. The log level has to be in upper case according to documentation
I was trying to replicate the error you posted
[warning] Use of undefined constant a - assumed 'a'
I thought that the undefined constant...
was coming from the type conversion.
If it is the uppercase that is the issue, we can certainly change the docs (easiest) or change the code. I don't mind doing either.
@Jeckerson thoughts?
@niden I think we should change to uppercase in the code, as in docs it always was uppercase, but never was noticed.
@kowach Because it is not intended to be changed. However, the method is protected and you can easily extend it and put naming as you wish.
This isn't a showstopper for me and isn't worth it to overwrite protected getLevels()
method. I just wondered about one more thing, silently changed. Because in Phalcon v3.4 the log level was printed uppercase to log (see code).
And from most other projects, the log level is used to be printed uppercase, too. So I prefer a change of code, but no hurry.
In case anyone is wondering. I remember why this was changed:
https://github.com/php-fig/log/blob/master/Psr/Log/LogLevel.php#L10
PSR has everything lowercase.
We will change it to upper to keep with 3.4. Maybe put an option in to have them up or down or something
Thanks for clarification. No problem if PSR requires it to be lowercase. But then it makes no sense do switch back to uppercase, doesn't it?
PSR does not "require" it I think so long as you can identify what the level is - uppercase or lowercase. I checked Monolog and they print out their levels in uppercase.
I will change it to the way 3.4 was (uppercase). Also since getLevels
is protected, it can be overridden if someone wants it to be lowercase
I will have the PR ready shortly
This has been resolved for v5
Using Phalcon v4.1.0 I've set following format for logger
[%date%] [%type%] %message%
but this results in:I expect, that type of message is written in uppercase.