czim/laravel-context-log-library

There is no license information available for the latest version (3.1.0) of this package.

Library for context logging for Laravel

Maintainers

👁 czim

Package info

github.com/czim/laravel-context-log-library

Homepage

pkg:composer/czim/laravel-context-log-library

Statistics

Installs: 11 497

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

3.1.0 2024-05-29 08:46 UTC

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Unknown License 6fbc360b886deef8ea062a19479845cc807afea0

  • Coen Zimmerman <opensource.woop@czim.nl>

jsonmonologlaravelformatting

This package is auto-updated.

Last update: 2026-06-29 01:11:57 UTC


README

👁 Latest Version on Packagist
👁 Software License
👁 Build Status
👁 Coverage Status

Context Logging library for Laravel

Helper library for standard setup of czim/laravel-json-context-logging.

This helps you to quickly create context channels for logging. It is not a requirement for using JSON context logging.

Version Compatibility

Laravel Package
6.0 - 8.0 1.0
9.0 2.0
10.0 and up 3.0

Installation

No installation required; however, classes must be bound manually in your service provider.

<?php

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();
 }
}

You will also have to set up your own event, which may extend Czim\LaravelContextLogging\Events\AbstractDebugEvent. The listener for that event should use the ContextLoggerFactoryInterface to make a logger, and the DebugEventLogPrepperInterface to render the event into loggable data to be logged by it.

Credits

License

The MIT License (MIT). Please see License File for more information.