Skip to content
Permalink
Browse files

Manual test of contextual bindings for loggers

* app/Test1.php writes to storage/logs/test1.log
* app/Test2.php writes to storage/logs/test2.log
* app/Test3.php writes to storage/logs/laravel.log
  • Loading branch information...
TheoKouzelis committed Sep 30, 2016
1 parent 0fc16ba commit a225cb66b9606bbdd8203652df0116941bec7b6c
@@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App;
class TestLog extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test:log';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
App::make('App\Test1');
App::make('App\Test2');
App::make('App\Test3');
}
}
@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
//
\App\Console\Commands\TestLog::class,
];
/**
@@ -2,9 +2,9 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@@ -2,12 +2,12 @@
namespace App;
use Monolog\Logger;
use Psr\Log\LoggerInterface;
use Illuminate\Database\Eloquent\Model;
class Test1
class Test1 extends Model
{
public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
public function __construct(\Psr\Log\LoggerInterface $log)
{
$log->info('test 1');
}
}
@@ -2,12 +2,12 @@
namespace App;
use Monolog\Logger;
use Psr\Log\LoggerInterface;
use Illuminate\Database\Eloquent\Model;
class Test2
class Test2 extends Model
{
public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
public function __construct(\Psr\Log\LoggerInterface $log)
{
$log->info('test 2');
}
}
@@ -2,12 +2,12 @@
namespace App;
use Illuminate\Log\Writer;
use Psr\Log\LoggerInterface;
use Illuminate\Database\Eloquent\Model;
class Test3
class Test3 extends Model
{
public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
public function __construct(\Psr\Log\LoggerInterface $log)
{
$log->info('test 3');
}
}
@@ -1,2 +0,0 @@
*
!.gitignore
@@ -0,0 +1,2 @@
[2016-09-30 22:38:32] production.INFO: test 3
[2016-09-30 22:43:30] production.INFO: test 3
@@ -0,0 +1,2 @@
[2016-09-30 22:38:32] test1.INFO: test 1 [] []
[2016-09-30 22:43:30] test1.INFO: test 1 [] []
@@ -0,0 +1,2 @@
[2016-09-30 22:38:32] test2.INFO: test 2 [] []
[2016-09-30 22:43:30] test2.INFO: test 2 [] []

0 comments on commit a225cb6

Please sign in to comment.
You can’t perform that action at this time.