Created
January 28, 2013 11:59
-
-
Save skinofstars/4654952 to your computer and use it in GitHub Desktop.
Just the a quick knock-up to add monolog to a class. You could just instantiate the logger in the function you're debugging, but this makes it easier to bounce around the class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Monolog\Logger; | |
use Monolog\Handler\StreamHandler; | |
class foo extends bar | |
{ | |
private $log = null; | |
public function __construct($swiftmailer, $service_container) | |
{ | |
// if your class extends, make sure you check for the parents constructor and pass whatever you need | |
parent::__construct($swiftmailer, $service_container); | |
$this->log = new Logger('name'); | |
$this->log->pushHandler(new StreamHandler('/path/to/app/logs/audit.log', Logger::WARNING)); | |
} | |
public function whateverNeedsDebugging() | |
{ | |
$this->log->addWarning('Foo'); | |
$this->log->addError('Bar'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment