Search code examples
phploggingsymfony1

Symfony Logging


In Java, I use log4J that is a logging framework. In Log4j you can do something like this:

if (log.isDebug()) {
  // do some expensive operation that should only be displayed if DEBUG is turned on
}

Reading some Symfony examples, I am unable to find a way to determine if DEBUG logging is activated in the current class context. Is there a way to do this?

if (--need something here--) {
  $this->logMessage('Expensive operation return value: '.expensiveFunction(), 'debug');
}

Solution

  • something like

    $this->getLogger()->getLogLevel() == sfLogger::DEBUG
    

    should do.