views:

651

answers:

1

During the day I am a Java developer, but at night I try stopping crime as a PHP superhero. My weapon of choice is symfony. We can say that I am training to be a superhero.

In Java, I use log4J, 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
}

In 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');
}
A: 

something like

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

should do.

ax
Thanks, I will be using this as a guide: http://www.symfony-project.org/api/1_2/sfLogger
mattsidesinger