Last active
December 17, 2015 17:09
-
-
Save mamor/5643801 to your computer and use it in GitHub Desktop.
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
/** | |
* Log to chrome | |
* | |
* required Chrome Logger | |
* https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd | |
* | |
* @param mixed $message | |
* @param string $logger | |
* @return boolean | |
*/ | |
public static function chrome($message, $logger = 'Logger') | |
{ | |
if (in_array(Fuel::$env, array(Fuel::TEST, Fuel::PRODUCTION))) | |
{ | |
return true; | |
} | |
$log = new Monolog\Logger($logger); | |
$log->pushHandler(new Monolog\Handler\ChromePHPHandler()); | |
if ($message instanceof Exception) | |
{ | |
$messages = array( | |
$message->getFile().' on line '.$message->getLine(), | |
$message->getMessage(), | |
$message->getTraceAsString() | |
); | |
$message = implode("\n", $messages); | |
} else if ( ! is_string($message)) | |
{ | |
$message = print_r($message, true); | |
} | |
return $log->addDebug($message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment