mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 08:14:25 +02:00
Add Monolog
This commit is contained in:
parent
518f28a7bf
commit
2e602afd3e
18 changed files with 736 additions and 164 deletions
33
src/App.php
33
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 Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -106,6 +108,11 @@ class App
|
|||
*/
|
||||
public $mobileDetect;
|
||||
|
||||
/**
|
||||
* @var LoggerInterface 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().
|
||||
|
@ -146,13 +153,16 @@ class App
|
|||
/**
|
||||
* @brief App constructor.
|
||||
*
|
||||
* @param string $basePath Path to the app base folder
|
||||
* @param bool $isBackend Whether it is used for backend or frontend (Default true=backend)
|
||||
* @param string $basePath Path to the app base folder
|
||||
* @param LoggerInterface $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, LoggerInterface $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 LoggerInterface 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');
|
||||
|
||||
Core\Logger::setLogger($this->logger);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue