mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-09 08:34:26 +02:00
Add Monolog
This commit is contained in:
parent
1d61645a16
commit
fe8f0e0045
15 changed files with 363 additions and 121 deletions
29
src/App.php
29
src/App.php
|
@ -8,8 +8,10 @@ use Detection\MobileDetect;
|
|||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
use Exception;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Monolog;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -106,6 +108,11 @@ class App
|
|||
*/
|
||||
public $mobileDetect;
|
||||
|
||||
/**
|
||||
* @var Monolog\Logger The current logger of this App
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* Register a stylesheet file path to be included in the <head> tag of every page.
|
||||
* Inclusion is done in App->initHead().
|
||||
|
@ -147,12 +154,15 @@ class App
|
|||
* @brief App constructor.
|
||||
*
|
||||
* @param string $basePath Path to the app base folder
|
||||
* @param Monolog\Logger Logger of this application
|
||||
* @param bool $isBackend Whether it is used for backend or frontend (Default true=backend)
|
||||
*
|
||||
* @throws Exception if the Basepath is not usable
|
||||
*/
|
||||
public function __construct($basePath, $isBackend = true)
|
||||
public function __construct($basePath, $logger, $isBackend = true)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
|
||||
if (!static::isDirectoryUsable($basePath, false)) {
|
||||
throw new Exception('Basepath ' . $basePath . ' isn\'t usable.');
|
||||
}
|
||||
|
@ -301,6 +311,21 @@ class App
|
|||
return $this->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Logger of the Application
|
||||
*
|
||||
* @return Monolog\Logger The Logger
|
||||
* @throws InternalServerErrorException when the logger isn't created
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
if (empty($this->logger)) {
|
||||
throw new InternalServerErrorException('Logger of the Application is not defined');
|
||||
}
|
||||
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the whole app instance
|
||||
*/
|
||||
|
@ -328,6 +353,8 @@ class App
|
|||
Core\L10n::init();
|
||||
|
||||
$this->process_id = Core\System::processID('log');
|
||||
|
||||
Logger::loadDefaultHandler($this->logger, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue