|
8 | 8 | use Monolog\Logger; |
9 | 9 | use Monolog\Handler\PsrHandler; |
10 | 10 | use Monolog\Handler\SyslogHandler; |
| 11 | +use Monolog\Handler\StreamHandler; |
11 | 12 | use A1comms\GaeSupportLaravel\Storage\Optimizer; |
12 | 13 |
|
13 | 14 | /** |
|
18 | 19 | * @package A1comms\GaeSupportLaravel\Foundation |
19 | 20 | */ |
20 | 21 | class LumenApplication extends \Laravel\Lumen\Application |
21 | | -{ |
22 | | - /** |
23 | | - * A custom callback used to configure Monolog. |
24 | | - * |
25 | | - * @var callable|null |
26 | | - */ |
27 | | - protected $monologConfigurator; |
28 | | - |
| 22 | +{ |
29 | 23 | /** |
30 | 24 | * The GAE app ID. |
31 | 25 | * |
@@ -74,22 +68,6 @@ public function __construct($basePath = null) |
74 | 68 |
|
75 | 69 | $this->detectGae(); |
76 | 70 |
|
77 | | - if ( is_gae_std() ) { |
78 | | - $this->configureMonologUsing(function ($monolog) { |
79 | | - $monolog->pushHandler(new SyslogHandler('laravel')); |
80 | | - }); |
81 | | - } else if ( is_gae_flex() ) { |
82 | | - $this->configureMonologUsing(function ($monolog) { |
83 | | - $monolog->pushHandler(new PsrHandler(new PsrBatchLogger('app'))); |
84 | | - }); |
85 | | - } else { |
86 | | - $this->configureMonologUsing(function (\Monolog\Logger $monolog) { |
87 | | - $handler = new \Monolog\Handler\StreamHandler($this->storagePath('logs/lumen.log')); |
88 | | - $handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, null, true, true)); |
89 | | - $monolog->pushHandler($handler); |
90 | | - }); |
91 | | - } |
92 | | - |
93 | 71 | $this->replaceDefaultSymfonyLineDumpers(); |
94 | 72 |
|
95 | 73 | $this->optimizer = new Optimizer($basePath, $this->runningInConsole()); |
@@ -249,30 +227,22 @@ public function storagePath() |
249 | 227 | } |
250 | 228 |
|
251 | 229 | /** |
252 | | - * Register container bindings for the application. |
253 | | - * |
254 | | - * @return void |
255 | | - */ |
256 | | - protected function registerLogBindings() |
257 | | - { |
258 | | - $this->singleton('Psr\Log\LoggerInterface', function () { |
259 | | - if ($this->monologConfigurator) { |
260 | | - return call_user_func($this->monologConfigurator, new Logger('lumen')); |
261 | | - } else { |
262 | | - return new Logger('lumen', [$this->getMonologHandler()]); |
263 | | - } |
264 | | - }); |
265 | | - } |
266 | | - |
267 | | - /** |
268 | | - * Define a callback to be used to configure Monolog. |
| 230 | + * Overrides the default implementation in order to |
| 231 | + * return a Syslog Monolog handler when running on GAE. |
269 | 232 | * |
270 | | - * @param callable $callback |
271 | | - * @return $this |
| 233 | + * @return \Monolog\Handler\AbstractHandler |
272 | 234 | */ |
273 | | - public function configureMonologUsing(callable $callback) |
| 235 | + protected function getMonologHandler() |
274 | 236 | { |
275 | | - $this->monologConfigurator = $callback; |
276 | | - return $this; |
| 237 | + if ( is_gae_std() ) { |
| 238 | + return new SyslogHandler('intranet', 'user', Logger::DEBUG, false, LOG_PID); |
| 239 | + } else if ( is_gae_flex() ) { |
| 240 | + return new PsrHandler(new PsrBatchLogger('app')); |
| 241 | + } else { |
| 242 | + $handler = new StreamHandler($this->storagePath('logs/lumen.log')); |
| 243 | + $handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, null, true, true)); |
| 244 | + return $handler; |
| 245 | + } |
| 246 | + return parent::getMonologHandler(); |
277 | 247 | } |
278 | 248 | } |
0 commit comments