PHP code example of czim / laravel-context-log-library
1. Go to this page and download the library: Download czim/laravel-context-log-library 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/ */
czim / laravel-context-log-library example snippets
use Czim\LaravelContextLogging\Config\StandardJsonContextConfigSource;
use Czim\LaravelContextLogging\Contracts\ContextLoggerFactoryInterface;
use Czim\LaravelContextLogging\Contracts\DebugEventLogPrepperInterface;
use Czim\LaravelContextLogging\Factories\ContextLoggerFactory;
class AppServiceProvider extends \Illuminate\Support\ServiceProvider
{
// ...
public function register(): void
{
$this->app->singleton(
DebugEventLogPrepperInterface::class,
\Your\JsonContextEventLogPrepper::class
);
$this->app->singleton(
ContextLoggerFactoryInterface::class,
function (): void {
$factory = new ContextLoggerFactory();
$factory->setConfigs($this->makeLogContextConfigArray());
return $factory;
}
);
}
protected function makeLogContextConfigArray(): array
{
return $this->app->make(StandardJsonContextConfigSource::class)
->enableContextLogging()
->makeConfigArray();
}
}