1. Go to this page and download the library: Download fotografde/logging library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fotografde / logging example snippets
class GuzzleRequestExceptionContext implements ExceptionContext
{
/**
* @return array{message?: string}
*/
public function __invoke(RequestException $exception): array
{
if ($exception->getResponse() !== null && $exception->getResponse()->getBody() !== null) {
return ['message' => $exception->getResponse()->getBody()->getContents()];
}
return [];
}
}
declare(strict_types=1);
use Gotphoto\Logging\LogstashFormatter;
use Gotphoto\Logging\OtelFormatter;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\MonologConfig;
return static function (MonologConfig $monolog, ContainerConfigurator $containerConfigurator): void {
$monolog->handler('newrelic')
->type('stream')
->path('php://stderr')
->formatter(LogstashFormatter::class)
// log start from info messages (debug is lowest level)
->level('info');
$monolog->handler('otel')
->type('service')
->id(Handler::class)
// log start from info messages (debug is lowest level)
->level('info');
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.