Skip to content

Commit 8aa1919

Browse files
authored
Update LumenApplication.php
1 parent de2baca commit 8aa1919

File tree

1 file changed

+16
-46
lines changed

1 file changed

+16
-46
lines changed

src/A1comms/GaeSupportLaravel/Foundation/LumenApplication.php

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Monolog\Logger;
99
use Monolog\Handler\PsrHandler;
1010
use Monolog\Handler\SyslogHandler;
11+
use Monolog\Handler\StreamHandler;
1112
use A1comms\GaeSupportLaravel\Storage\Optimizer;
1213

1314
/**
@@ -18,14 +19,7 @@
1819
* @package A1comms\GaeSupportLaravel\Foundation
1920
*/
2021
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+
{
2923
/**
3024
* The GAE app ID.
3125
*
@@ -74,22 +68,6 @@ public function __construct($basePath = null)
7468

7569
$this->detectGae();
7670

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-
9371
$this->replaceDefaultSymfonyLineDumpers();
9472

9573
$this->optimizer = new Optimizer($basePath, $this->runningInConsole());
@@ -249,30 +227,22 @@ public function storagePath()
249227
}
250228

251229
/**
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.
269232
*
270-
* @param callable $callback
271-
* @return $this
233+
* @return \Monolog\Handler\AbstractHandler
272234
*/
273-
public function configureMonologUsing(callable $callback)
235+
protected function getMonologHandler()
274236
{
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();
277247
}
278248
}

0 commit comments

Comments
 (0)