Reputation: 21
How can I retrieve the log level in Laravel?
I'd like to do something like this:
if ( Log::isInfo() ) {
...
}
for instance, in log4java, you have the methods isDebug, isInfo, etc.
In the example, the idea is that isInfo tests if a message in Info level would be logged, so, if the log level is debug or info, it returns true.
The idea is to bypass some piece of code that I only execute to log some detail.
(i'm still using Laravel 4.2)
Upvotes: 0
Views: 255
Reputation: 21
Well, surfing the API documentation in Laravel and Monolog, I arrived at this solution:
if ( Log::getMonolog()->isHandling( Log::getMonolog()->toMonologLevel("INFO") ) ) {
....
}
I'd prefer something prettier, but it works...
Upvotes: 1