Files
nextcloud-docs/developer_manual/basics/logging.rst
Christoph Wurst 5111715c34 Migrate logging docs to new interface
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2020-10-05 14:30:43 +02:00

46 lines
864 B
ReStructuredText

=======
Logging
=======
.. sectionauthor:: Bernhard Posselt <dev@bernhard-posselt.com>
The logger is present by default in the container. The app that is logging is
set automatically.
The logger can be used in the following way:
.. code-block:: php
<?php
namespace OCA\MyApp\Service;
use Psr\Log\LoggerInterface;
class AuthorService {
private $logger;
private $appName;
public function __construct(LoggerInterface $logger, string $appName){
$this->logger = $logger;
$this->appName = $appName;
}
public function log($message) {
$this->logger->error($message, ['extra_context' => 'my extra context']);
}
}
The following methods are available:
* **emergency**
* **alert**
* **critical**
* **error**
* **warning**
* **notice**
* **info**
* **debug**