consilience / laravel-extended-logging by judgej

Extend Laravel and Lumen logging to better support containers
21,191
7
3
Package Data
Maintainer Username: judgej
Maintainer Contact: jason.judge@consil.co.uk (Jason Judge)
Package Create Date: 2019-12-01
Package Last Update: 2023-09-21
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:20:35
Package Statistics
Total Downloads: 21,191
Monthly Downloads: 210
Daily Downloads: 5
Total Stars: 7
Total Watchers: 3
Total Forks: 6
Total Open Issues: 0

Latest Stable Version Total Downloads Latest Unstable Version License

Laravel and Lumen Extended Logging

Provide some ready-made logging extensions to make it easier to deploy Laravel and Lumen into multiple containers.

The main features are:

  • A bunch of useful standard monolog processors.
  • Laravel user ID, if available.
  • Fully qualified class name of the job that is running.
  • A sequence number so logs can be reordered when they get mixed up.
  • Application name and subsystem name.

Installation

While under early development, in composer.json:

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/consilience/laravel-extended-logging.git"
        }
    ]

Then:

php composer require "consilience/laravel-extended-logging: *"

Lumen requires the provider to be registered in bootstrap/app.php so that the package can keep track of the name of the job currently running:

$app->register(Consilience\Laravel\ExtendedLogging\LoggingServiceProvider::class);

Configuration

The main configiration happens through the Laravel config/logging.php configuration script, by adding a channel.

<?php

use Monolog\Handler\StreamHandler;
use Monolog\Formatter\JsonFormatter;
use Consilience\Laravel\ExtendedLogging\Tap as ExtendedTap;

// ...

    'channels' => [
        'my-extended-logging-channel' => [
            //
            // monolog is the underlying driver.
            //
            'driver' => 'monolog',
            //
            // This is the handler to use within monolog, with any parameters to configure it.
            // Handlers can be found in \Monolog\Handler namespace.
            //
            'handler' => StreamHandler::class,
            //
            // Parameters for the monolog handler.
            //
            'with' => [
                'stream' => 'php://stderr',
            ],
            //
            // The custom tap to offer additional manipulation of the log output.
            // Other taps from other packages can be added here to extend further.
            //
            'tap' => [
                ExtendedTap::class,
            ],
            //
            // The output formatter.
            // The standard Monolog json formatter has a good structure that is easy to parse.
            //
            'formatter' => JsonFormatter::class,
            'formatter_with' => [],
        ],
    ],

TODO

  • Tests.
  • Config to turn features on and off.