PHP code example of salvakexx / laravel-email-logger

1. Go to this page and download the library: Download salvakexx/laravel-email-logger 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/ */

    

salvakexx / laravel-email-logger example snippets


'providers' => [
  /*
   * Package Service Providers...
   */
   Salvakexx\EmailLogger\EmailLoggerServiceProvider::class,
],

'aliases' => [
  /*
   * Class Aliases...
   */
   'EmailLogger' => \Salvakexx\EmailLogger\EmailLoggerFacade::class,
],

    'emails' => [
        //fill this array with emails that will receive logs
    ],
//    'emails'    => explode(',',env('MAIL_LOGGER_EMAILS')),

  \EmailLogger::info(request(),'Information on action etc. ');
  
  \EmailLogger::error($exception,request(),'Error happened please check');

    
    
    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $exception)
    {
        //exclude the common exceptions
        $exception = $this->prepareException($exception);
        if(
            !$exception instanceof NotFoundHttpException
            && !$exception instanceof AuthenticationException
            && !$exception instanceof ValidationException
        ){
            \EmailLogger::error($exception,$request,'Internal Server Error happened');
        }
        
        //Track user camed to 404
        if($exception instanceof NotFoundHttpException){
            \EmailLogger::info($request,'User lost somehow check please');
        }

        return parent::render($request, $exception);
    }

shell
php artisan vendor:publish --provider="Salvakexx\EmailLogger\EmailLoggerServiceProvider"