PHP code example of deprecationsio / monolog-handler

1. Go to this page and download the library: Download deprecationsio/monolog-handler 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/ */

    

deprecationsio / monolog-handler example snippets


use Deprecationsio\Monolog\Client\CurlDeprecationsioClient;
use Deprecationsio\Monolog\Handler\MonologV1Handler;
use Deprecationsio\Monolog\Handler\MonologV2Handler;
use Deprecationsio\Monolog\Handler\MonologV3Handler;
use Monolog\Logger;

$logger = new Logger('app', [
    // Monolog 1
    new MonologV1Handler('<your-deprecations.io-endpoint>'),
    
    // Monolog 2
    new MonologV2Handler('<your-deprecations.io-endpoint>'),
    
    // Monolog 3
    new MonologV3Handler('<your-deprecations.io-endpoint>'),
]);

// Log a deprecation
// A deprecation must contain an exception that will be used by developers to understand the stacktrace
$logger->notice('User Deprecated: ...', [
    'exception' => $this->createDeprecationException(),
]);

use Deprecationsio\Monolog\MonologHandlerClassNameResolver;

$handlerName = MonologHandlerClassNameResolver::resolveHandlerClassName();

$logger = new Logger('app', [
    new $handlerName('<your-deprecations.io-endpoint>'),
]);