Skip to content

Instantly share code, notes, and snippets.

@mamor
Last active December 17, 2015 17:09
Show Gist options
  • Save mamor/5643801 to your computer and use it in GitHub Desktop.
Save mamor/5643801 to your computer and use it in GitHub Desktop.
/**
* 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