1. Go to this page and download the library: Download kasan/logger-package library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kasan / logger-package example snippets
'providers' => [
// Other service providers...
kashirin\rabbit_mq\RabbitLoggerServiceProvider::class,
],
use kashirin\rabbit_mq\Log;
public function render($request, Exception $exception)
{
//init and configure logger
$config = config('services.rabbit_log');
$logger = new Log($config);
$logger->error($exception);
return parent::render($request, $exception);
}
protected $middleware = [
// Other app middlewares...
\kashirin\rabbit_mq\Middlewares\ResponseHandlerMiddleware::class,
];
use Illuminate\Http\Request;
use kashirin\rabbit_mq\Log;
/**
* Class IndexController
* @package App\Http\Controllers
*/
class IndexController extends Controller
{
/**
* @param Request $request
* @param Log $log
* @return array
* @throws \AMQPChannelException
* @throws \AMQPConnectionException
* @throws \AMQPExchangeException
*/
public function index(Request $request, Log $log)
{
$response = [];
//some logic
//simply message log
$log->info('message to log');
try {
$data = 'some logic';
} catch (Exception $exception) {
//log any Throwable error or exception
$log->error($exception);
}
//this type of logs except to use Response and Request objects from Laravel. Used in middleware.
$log->log($response, $request);
//log any JsonSerializable data
$log->debug($data);
return $response;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.