Ejemplo n.º 1
0
 public function __construct($config = null)
 {
     ini_set('max_execution_time', 300);
     //var_dump($config["url"]);exit
     if (!$config) {
         $config = Config::get('api');
     }
     $this->logFile = base_path() . '/logs/sii-api.log';
     if (!is_array($config)) {
         throw new Exception("Error: no configuration for Sii");
     } elseif (!array_key_exists("url", $config)) {
         throw new Exception("Error: no url was found");
     } elseif (!array_key_exists("name", $config)) {
         throw new Exception("Error: No name for app was found");
     } elseif (!array_key_exists("password", $config)) {
         throw new Exception("Error: No password for app was found");
     } else {
         $this->url = $config["url"];
         $this->name = $config["name"];
         $this->password = $config["password"];
         $this->proxy = $config['proxy'];
         $curr_user = Session::get('user');
         $this->token = $curr_user['persona']['token'];
         //$this->client = new Buzz\Client\FileGetContents();
         $this->client = new Buzz\Client\Curl();
         $this->client->setTimeout(60);
         $this->response = new Buzz\Message\Response();
         Log::useFiles($this->logFile, App::environment('local', 'staging') ? 'debug' : 'critical');
     }
     //$this->client = $buzz;
 }
Ejemplo n.º 2
0
 /**
  * Paypal cart payment ipn handler
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function payment()
 {
     try {
         \DB::beginTransaction();
         $listener = new Listener();
         $verifier = new SocketVerifier();
         // $ipn = \Input::all();
         $ipnMessage = Message::createFromGlobals();
         // uses php://input
         $verifier->setIpnMessage($ipnMessage);
         $verifier->setEnvironment(\Config::get('app.paypal_mode'));
         $listener->setVerifier($verifier);
         $listener->onVerifiedIpn(function () use($listener) {
             $ipn = [];
             $messages = $listener->getVerifier()->getIpnMessage();
             parse_str($messages, $ipn);
             if ($order = EloquentOrderRepository::find(\Input::get('custom'))) {
                 /**
                  * Check the paypal payment.
                  *
                  * Total sales ==  ipn['mc_gross']
                  *
                  * Driver Paypal Account == ipn['business]
                  */
                 if ($ipn['payment_status'] == 'Completed' && $order->total_sales == $ipn['payment_gross'] && $order->OrderDriver()->paypal_account == $ipn['business']) {
                     \Event::fire('paxifi.paypal.payment.' . $ipn['txn_type'], [$order->payment, $ipn]);
                     $products = $order->products;
                     $products->map(function ($product) {
                         // Fires an event to update the inventory.
                         \Event::fire('paxifi.product.ordered', array($product, $product['pivot']['quantity']));
                         // Fires an event to notification the driver that the product is in low inventory.
                         if (EloquentProductRepository::find($product->id)->inventory <= 5) {
                             \Event::fire('paxifi.notifications.stock', array($product));
                         }
                     });
                 }
                 \DB::commit();
             }
         });
         $listener->listen(function () use($listener) {
             $resp = $listener->getVerifier()->getVerificationResponse();
         }, function () use($listener) {
             // on invalid IPN (somethings not right!)
             $report = $listener->getReport();
             $resp = $listener->getVerifier()->getVerificationResponse();
             \Log::useFiles(storage_path() . '/logs/' . 'error-' . time() . '.txt');
             \Log::info($report);
             return $this->setStatusCode(400)->respondWithError('Payment failed.');
         });
     } catch (\RuntimeException $e) {
         return $this->setStatusCode(400)->respondWithError($e->getMessage());
     } catch (\Exception $e) {
         print_r($e->getMessage());
         return $this->errorInternalError();
     }
 }
Ejemplo n.º 3
0
 public function testNotFoundRender()
 {
     $path = base_path('tests/storage/logs/report.log');
     \Log::useFiles($path);
     $exception = new \Illuminate\Database\Eloquent\ModelNotFoundException();
     $exception->setModel('Testing');
     $response = $this->handler->render($this->app['request'], $exception);
     $this->assertSame(404, $response->getStatusCode());
     $this->beforeApplicationDestroyed(function () use($path) {
         \File::delete($path);
     });
 }
 /**
  * リスト6.33:makePartial を利用するパーシャルモック
  */
 public function testBroadcastPartial()
 {
     $broadcastLog = base_path('/tests/tmp/broadcast.log');
     \Log::useFiles($broadcastLog);
     $mock = \Mockery::mock(new \App\Publisher(new \Illuminate\Broadcasting\BroadcastManager($this->app)))->makePartial();
     $mock->shouldReceive('channel')->andReturn('laravel5.1');
     $mock->broadcast([]);
     $this->assertFileExists($broadcastLog);
     $this->beforeApplicationDestroyed(function () use($broadcastLog) {
         \File::delete($broadcastLog);
     });
 }
 public function testUserRegister()
 {
     $path = base_path('tests/storage/logs/user_register.log');
     \Log::useFiles($path);
     $user = $this->service->registerUser([]);
     $this->assertFileExists($path);
     $content = file_get_contents($path);
     $this->assertNotFalse(strpos($content, '*****@*****.**'));
     $this->assertNotFalse(strpos($content, 'ユーザー登録が完了しました'));
     $this->assertNotFalse(strpos($content, 'testing'));
     $this->beforeApplicationDestroyed(function () use($path) {
         \File::delete($path);
     });
 }
 /**
  * ユーザー作成が行われることをテストします
  * ユーザー作成時に送信されるメールは、テストではログに出力されるように設定しています
  * 'phpunit.xml内の<env name="MAIL_DRIVER" value="log" />'
  */
 public function testPostUserRegister()
 {
     $this->registerTestLogger();
     $mailLog = base_path('/tests/storage/logs/mail.log');
     // ログで利用するファイルをtests配下に変更します
     \Log::useFiles($mailLog);
     $this->visit('/auth/register')->type('laravel5', 'name')->type('*****@*****.**', 'email')->type('testing', 'password')->type('testing', 'password_confirmation')->type(session('captcha.phrase'), 'captcha_code')->press('アカウント作成');
     // ファイルが出力されたかどうかを確認します
     $this->assertFileExists($mailLog);
     // メールに記載されている内容をテストできます
     $this->assertNotFalse(strpos(file_get_contents($mailLog), '*****@*****.**'));
     // テスト終了時に行う処理を記述します
     $this->beforeApplicationDestroyed(function () use($mailLog) {
         // ログファイルの削除を行います
         \File::delete($mailLog);
     });
 }
Ejemplo n.º 7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $filename = $this->argument('filename');
     if (!$this->option('web-importer')) {
         $logFile = $this->option('logfile');
         \Log::useFiles($logFile);
         if ($this->option('testrun')) {
             $this->comment('====== TEST ONLY Asset Import for ' . $filename . ' ====');
             $this->comment('============== NO DATA WILL BE WRITTEN ==============');
         } else {
             $this->comment('======= Importing Assets from ' . $filename . ' =========');
         }
     }
     if (!ini_get("auto_detect_line_endings")) {
         ini_set("auto_detect_line_endings", '1');
     }
     $csv = Reader::createFromPath($this->argument('filename'));
     $csv->setNewline("\r\n");
     $results = $csv->fetchAssoc();
     $newarray = null;
     foreach ($results as $index => $arraytoNormalize) {
         $internalnewarray = array_change_key_case($arraytoNormalize);
         $newarray[$index] = $internalnewarray;
     }
     $this->locations = Location::All(['name', 'id']);
     $this->categories = Category::All(['name', 'category_type', 'id']);
     $this->manufacturers = Manufacturer::All(['name', 'id']);
     $this->asset_models = AssetModel::All(['name', 'modelno', 'category_id', 'manufacturer_id', 'id']);
     $this->companies = Company::All(['name', 'id']);
     $this->status_labels = Statuslabel::All(['name', 'id']);
     $this->suppliers = Supplier::All(['name', 'id']);
     $this->assets = Asset::all(['asset_tag']);
     $this->accessories = Accessory::All(['name']);
     $this->consumables = Consumable::All(['name']);
     $this->customfields = CustomField::All(['name']);
     $bar = null;
     if (!$this->option('web-importer')) {
         $bar = $this->output->createProgressBar(count($newarray));
     }
     // Loop through the records
     DB::transaction(function () use(&$newarray, $bar) {
         Model::unguard();
         $item_type = strtolower($this->option('item-type'));
         foreach ($newarray as $row) {
             // Let's just map some of these entries to more user friendly words
             // Fetch general items here, fetch item type specific items in respective methods
             /** @var Asset, License, Accessory, or Consumable $item_type */
             $item_category = $this->array_smart_fetch($row, "category");
             $item_company_name = $this->array_smart_fetch($row, "company");
             $item_location = $this->array_smart_fetch($row, "location");
             $item_status_name = $this->array_smart_fetch($row, "status");
             $item["item_name"] = $this->array_smart_fetch($row, "item name");
             if ($this->array_smart_fetch($row, "purchase date") != '') {
                 $item["purchase_date"] = date("Y-m-d 00:00:01", strtotime($this->array_smart_fetch($row, "purchase date")));
             } else {
                 $item["purchase_date"] = null;
             }
             $item["purchase_cost"] = $this->array_smart_fetch($row, "purchase cost");
             $item["order_number"] = $this->array_smart_fetch($row, "order number");
             $item["notes"] = $this->array_smart_fetch($row, "notes");
             $item["quantity"] = $this->array_smart_fetch($row, "quantity");
             $item["requestable"] = $this->array_smart_fetch($row, "requestable");
             $item["asset_tag"] = $this->array_smart_fetch($row, "asset tag");
             $this->current_assetId = $item["item_name"];
             if ($item["asset_tag"] != '') {
                 $this->current_assetId = $item["asset_tag"];
             }
             $this->log('Category: ' . $item_category);
             $this->log('Location: ' . $item_location);
             $this->log('Purchase Date: ' . $item["purchase_date"]);
             $this->log('Purchase Cost: ' . $item["purchase_cost"]);
             $this->log('Company Name: ' . $item_company_name);
             $this->log('Status: ' . $item_status_name);
             $item["user"] = $this->createOrFetchUser($row);
             $item["location"] = $this->createOrFetchLocation($item_location);
             $item["category"] = $this->createOrFetchCategory($item_category, $item_type);
             $item["manufacturer"] = $this->createOrFetchManufacturer($row);
             $item["company"] = $this->createOrFetchCompany($item_company_name);
             $item["status_label"] = $this->createOrFetchStatusLabel($item_status_name);
             switch ($item_type) {
                 case "asset":
                     // -----------------------------
                     // CUSTOM FIELDS
                     // -----------------------------
                     // Loop through custom fields in the database and see if we have any matches in the CSV
                     foreach ($this->customfields as $customfield) {
                         if ($item['custom_fields'][$customfield->db_column_name()] = $this->array_smart_custom_field_fetch($row, $customfield)) {
                             $this->log('Custom Field ' . $customfield->name . ': ' . $this->array_smart_custom_field_fetch($row, $customfield));
                         }
                     }
                     $this->createAssetIfNotExists($row, $item);
                     break;
                 case "accessory":
                     $this->createAccessoryIfNotExists($item);
                     break;
                 case 'consumable':
                     $this->createConsumableIfNotExists($item);
                     break;
             }
             if (!$this->option('web-importer')) {
                 $bar->advance();
             }
             $this->log('------------- Action Summary ----------------');
         }
     });
     if (!$this->option('web-importer')) {
         $bar->finish();
     }
     $this->log('=====================================');
     if (!$this->option('web-importer')) {
         if (!empty($this->errors)) {
             $this->comment("The following Errors were encountered.");
             foreach ($this->errors as $asset => $error) {
                 $this->comment('Error: Item: ' . $asset . 'failed validation: ' . json_encode($error));
             }
         } else {
             $this->comment("All Items imported successfully!");
         }
     } else {
         if (empty($this->errors)) {
             return 0;
         } else {
             $this->comment(json_encode($this->errors));
             //Send a big string to the
             return 1;
         }
     }
     $this->comment("");
     return 2;
 }
Ejemplo n.º 8
0
| your classes in the "global" namespace without Composer updating.
|
*/
// PSR-4のため不要なものを削除
\ClassLoader::addDirectories([app_path() . '/database/seeds']);
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
\Log::useFiles(storage_path() . '/logs/laravel' . date("Ymd") . '.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
\App::error(function (\Exception $exception, $code) {
    \Log::error($exception);
    return \Response::view('error', []);
Ejemplo n.º 9
0
|
| Here we are binding the paths configured in paths.php to the app. You
| should not be changing these here. If you need to change these you
| may do so within the paths.php file and they will be bound here.
|
*/
$app->bindInstallPaths(require __DIR__ . '/paths.php');
/*
|--------------------------------------------------------------------------
| Load The Application
|--------------------------------------------------------------------------
|
| Here we will load this Illuminate application. We will keep this in a
| separate location so we can isolate the creation of an application
| from the actual running of the application with a given request.
|
*/
$framework = $app['path.base'] . '/vendor/laravel/framework/src';
require $framework . '/Illuminate/Foundation/start.php';
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
Log::useFiles('php://stdout', 'info');
return $app;
Ejemplo n.º 10
0
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/libraries', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
$logFile = 'solderlog-' . date('Y-m-d') . '.txt';
Log::useFiles(storage_path() . '/logs/' . $logFile);
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    Log::error($exception);
    if (!Config::get('app.debug') && !App::runningInConsole()) {
Ejemplo n.º 11
0
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/system.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    Log::error($exception);
});
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/app.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    Log::error($exception);
});
Ejemplo n.º 13
0
DB::listen(function($sql, $bindings, $times) {
    $queries = DB::getQueryLog();
    $last_query = end($queries);
    
    Log::useFiles(storage_path() . '/logs/ropc_log_query.log', 'alert');
    Log::alert('', array('user' => Session::get('usuario.username'),
        ',proceso' => Session::get('proceso'),
        ',host' => Config::get('database.connections.oracle.host'),
        ',bd' => DB::getDatabaseName(),
        ',service_name' => Config::get('database.connections.oracle.service_name'),
        ',consulta' => $last_query,
        ',times' => $times
    ));
});
*/
/* * ************* GUARDAR LOG DE ERRORES*************** */
App::error(function (Exception $exc, $code) {
    Log::useFiles(storage_path() . '/logs/ropc_log_error.log', 'error');
    Log::error('', array('user' => Session::get('usuario.username'), ',proceso' => Session::get('proceso'), ',Error' => $exc->getMessage(), ',Tracer' => $exc->getTraceAsString(), ',code' => $code));
});
/*
 |--------------------------------------------------------------------------
 | Require The Filters File
 |--------------------------------------------------------------------------
 |
 | Next we will load the filters file for the application. This gives us
 | a nice separate location to store our route and application filter
 | definitions instead of putting them all in the main routes file.
 |
*/
require app_path() . '/filters.php';
Ejemplo n.º 14
0
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
// Log::useFiles(storage_path().'/logs/laravel.log');
Log::useFiles('php://stderr');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    Log::error($exception);
});
Ejemplo n.º 15
0
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/subbly.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    Log::error($exception);
});
Ejemplo n.º 16
0
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
$mytime = Carbon\Carbon::now();
$year = $mytime->year;
$month = $mytime->month;
$day = $mytime->day;
Log::useFiles(storage_path() . '/logs/logqlm_' . $year . $month . $day . '.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    Log::error($exception);
});
Ejemplo n.º 17
0
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
if (!Config::get('app.debug')) {
    Log::useFiles(storage_path() . '/logs/errores_produccion.log');
} else {
    Log::useFiles(storage_path() . '/logs/errores_desarrollo.log');
}
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    $ip = Request::getClientIp();
Ejemplo n.º 18
0
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/pitimi.log');
$monolog = Log::getMonolog();
$monolog->pushProcessor(function ($record) {
    $record['extra']['user'] = Auth::user() ? Auth::user()->username : '******';
    $record['extra']['ip'] = Request::getClientIp();
    return $record;
});
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
Ejemplo n.º 19
0
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/mylog.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function (Exception $exception, $code) {
    Log::error($exception);
});
Ejemplo n.º 20
0
 /**
  * test method for isExist
  * some http error
  */
 public function testIsExistHttpFailed()
 {
     // guzzle mock
     $client = $this->guzzleMockFactory(new Response(404));
     // self mock
     $yoService = $this->getMockBuilder('App\\Services\\YoService')->setMethods(['getHttpClient'])->getMock();
     $yoService->expects($this->once())->method('getHttpClient')->will($this->returnValue($client));
     // log settings
     $path = base_path('tests/storage/logs/yo.log');
     \Log::useFiles($path);
     // mock data
     $mockUser = '******';
     // assertsion
     $this->assertFalse($yoService->isExist($mockUser));
     $this->assertFileExists($path);
     $log = file_get_contents($path);
     $this->assertNotFalse(strpos($log, $mockUser));
     $this->assertNotFalse(strpos($log, 'Checking Yo Account'));
     $this->assertNotFalse(strpos($log, 'error message'));
     // remove log
     $this->beforeApplicationDestroyed(function () use($path) {
         \File::delete($path);
     });
 }
Ejemplo n.º 21
0
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/laravel.log');
/*
|--------------------------------------------------------------------------
| Require The Errors File
|--------------------------------------------------------------------------
|
| Next we'll load the file responsible for error handling. This allow
| us to have error handling setup before we boot our application.
|
*/
require __DIR__ . '/errors.php';
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
Ejemplo n.º 22
0
<?php

//--------------------------------------------------------------------------
// Application Error Logger
//--------------------------------------------------------------------------
Log::useFiles(storage_path() . 'Logs' . DS . 'error.log');
//--------------------------------------------------------------------------
// Application Error Handler
//--------------------------------------------------------------------------
use Exception\RedirectToException;
App::error(function (Exception $exception, $code) {
    // Do not log the Redirect Exceptions.
    if (!$exception instanceof RedirectToException) {
        Log::error($exception);
    }
});
//--------------------------------------------------------------------------
// Application Missing Route Handler
//--------------------------------------------------------------------------
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
App::missing(function (NotFoundHttpException $exception) {
    $status = $exception->getStatusCode();
    $headers = $exception->getHeaders();
    if (Request::ajax()) {
        // An AJAX request; we'll create a JSON Response.
        $content = array('status' => $status);
        // Setup propely the Content Type.
        $headers['Content-Type'] = 'application/json';
        return Response::json($content, $status, $headers);
    }
    // We'll create the templated Error Page Response.