Laravel log, how to retrieve the level?

216 views Asked by At

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)

1

There are 1 answers

0
Daniel Francesch On

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...