Created
June 27, 2013 14:07
-
-
Save ckdarby/5876705 to your computer and use it in GitHub Desktop.
Just messing around with monolog
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 | |
include_once('vendor/autoload.php'); | |
use Monolog\Logger; | |
use Monolog\Handler\StreamHandler; | |
use Monolog\Formatter\LineFormatter; | |
//Create a log channel | |
$log = new Logger('Test'); | |
//Create formatter for different logging than default | |
$dateFormat = "Y n j, g:i a"; | |
$output = "%datetime% > %level_name% > %message% %context% %extra%\n"; | |
$formatter = new LineFormatter($output, $dateFormat); | |
//Create handler | |
$handler = new StreamHandler('/var/log/mono', Logger::WARNING); | |
//Set formatter | |
$handler->setFormatter($formatter); | |
//Set Handler | |
$log->pushHandler($handler); | |
//Add records | |
$log->addWarning('Foo'); | |
$log->addError('Bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment